/**

  * 安装APK文件

  */

 private void installApk() {

  File apkfile = new File(mSavePath,Constant.appFileName);

  if (!apkfile.exists()) {

   return;

  }

  // 通过Intent安装APK文件

  Intent i = new Intent(Intent.ACTION_VIEW); 

  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

  i.setDataAndType(Uri.parse("file://" + apkfile.toString()),

    "application/vnd.android.package-archive");

  mContext.startActivity(i);

  android.os.Process.killProcess(android.os.Process.myPid());

 }

如果没有android.os.Process.killProcess(android.os.Process.myPid());最后不会提示完成、打开。

如果没有i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);这一步的话,最后安装好了,点打开,是不会打开新版本应用的。

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2021-11-17
  • 2021-10-05
  • 2021-05-22
  • 2021-10-12
  • 2021-08-16
  • 2021-10-28
猜你喜欢
  • 2021-05-03
  • 2021-08-27
  • 2021-09-08
  • 2021-10-14
  • 2022-02-08
  • 2021-04-13
  • 2021-07-15
相关资源
相似解决方案