zoukankan      html  css  js  c++  java
  • 安装应用

    /**

      * 安装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);这一步的话,最后安装好了,点打开,是不会打开新版本应用的。

  • 相关阅读:
    L1-031 到底是不是太胖了
    L1-030 一帮一
    PyCharm--git配置
    websocket--python
    UDP--python
    TCP--python
    pytest--metadata
    pytest--xdist
    pytest--夹具
    pytest--变量
  • 原文地址:https://www.cnblogs.com/spring87/p/5407720.html
Copyright © 2011-2022 走看看