Android: how to open an apk file after downloading for auto-update?

后端 未结 2 701
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 12:45

I have an application that I\'d like to add auto-update functionality (it\'s not in the marketplace). I have all the code in place that would check to see if there is an up

2条回答
  •  暖寄归人
    2020-12-15 13:08

    This will start the installation process

    File apkFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/packageName.apk");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    startActivity(intent);
    

提交回复
热议问题