代码如下:
/*  
     * 从服务器中下载APK  
     */     protected void downLoadApk() { 
        final ProgressDialog pd;    //进度条对话框     
        pd = new  ProgressDialog(this);    
        pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);    
        pd.setMessage("正在下载更新");    
        pd.show();  
        //adpage.this.AlertMSG(info.getUrl());        new Thread(){    
            @Override    
            public void run() {    
                try {    
                    File file = getFileFromServer1(info.getUrl(), pd);  
                    sleep(3000);    
                    installApk(file);    
                    pd.dismiss(); //结束掉进度条对话框
                } catch (Exception e) {    
                    Message msg = new Message();
                    msg.what = DOWN_ERROR;
                    handler.sendMessage(msg);    
                    e.printStackTrace();    
                }    
            }}.start();
    }  //服务器端获取APK信息 
    public File getFileFromServer1(String path, ProgressDialog pd) {
    // 如果相等的话表示当前的sdcard挂载在手机上并且是可用的
    try {
    if (Environment.getExternalStorageState().equals(
    Environment.MEDIA_MOUNTED)) {
    URL url = new URL(path);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    // 自带获取到文件的大小
    int Max = conn.getContentLength();
    pd.setMax(Max);
    InputStream is = conn.getInputStream();
    // 新建一个文件路径以及保存的软件名称
    File file = new File(Environment.getExternalStorageDirectory().getPath(),"wmh.apk");
    FileOutputStream fos = new FileOutputStream(file);
    BufferedInputStream bis = new BufferedInputStream(is);
    byte[] buffer = new byte[2048];
    int len;
    int total = 0;
    while ((len = bis.read(buffer)) != -1) {
    fos.write(buffer, 0, len);
    total += len;
    // 获取当前下载量
    pd.setProgress(total);
    }
    fos.close();
    bis.close();
    is.close();
    conn.disconnect();
    return file;
    } 
    else {
     return null;
    }
    } 
    catch (Exception e) {
    Message msg = new Message();
    msg.what = GET_UNDATAINFO_ERROR;
    handler.sendMessage(msg);
    return null;
    }
    }安装完第一次执行,检测到版本不一样,下载更新安装,没有问题。
第二次再次登录的时候,提示版本不一样,点击确定,下载,但是失败。
现在是测试阶段,版本还是原来的,程序里写的也是死的,每次登录都让提示下载。为什么第一次安装后,能下载,并能安装,只下载不安装,下次登录还能下载安装(正常)一旦提示下载安装后,再次运行,就下载不下来了?手机