I got an answer. Intent.ACTION_INSTALL_PACKAGE is the best choice. If your application is registered as a package installer, use the sample code below to bypass the selection dialog:
intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setData(Uri.fromFile(file)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
If you want to use the standard package installer, use the following code:
File apkFile = new File(apkFileString); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); mContext.startActivity(intent);
source share