1.各位大神谁可以帮忙看出我这里更新的问题
2.新版本的文件下载存储都没有问题,读取也没问题
3.总是走到安装的那一步【点击同意并安装】这个按钮就告诉我,应用未安装
//更新代码逻辑
protected void UpdateApp() {
final ProgressDialog pd; //进度条对话框
pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setMessage(getResources().getString(R.string.msg_downloading_update));
pd.show();
new Thread(){
@Override
public void run() {
try {
//File file = kApplication.DownloadFile(AppURL, pd);
//String path = Environment.getExternalStorageDirectory()+"/";
String path = Environment.getExternalStorageDirectory().toString() + "/shidoe";
int i = AppURL.lastIndexOf("/");
String FileName= AppURL.substring(i + 1);
//File file = downLoadFromUrl(AppURL,FileName,path);
String pp = path+File.separator+FileName;
if(fileIsExists(pp))
{
//installApk4(pp);
//sleep(2000);
install3(pp);
//installApk2(pp);
//installApk(file);
}else
{
Toast.makeText(HomeGrid.this,
"未发现程序安装包", Toast.LENGTH_SHORT).show();
}
pd.dismiss(); //结束掉进度条对话框
} catch (Exception e) {
Log.i("DSK___loader.java___>>","dsk---------- Run Downloadfile or installapk failed" );
Log.i("DSK___loader.java___>>","dsk-" + e.toString() );
}
}}.start();
}
private void install3(String filePath) {
Log.i("安装", "开始执行安装: " + filePath);
File apkFile = new File(filePath);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= 24) {
Log.w("安装", "版本大于 N ,开始使用 fileProvider 进行安装");
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = FileProvider.getUriForFile(
this
, "com.dsk.chinacrown.fileprovider"
, apkFile);
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
Log.w("安装", "正常进行安装");
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
}
startActivity(intent);
}