Android 6.0 Intent installation apk flash back, androidapk
Requirement Description:
Use DownloadManager in android to download the apk file and open the installation interface.
Problem description:
There are many examples of DownloadManager usage online. After the download is complete, the installation interface is opened in the android6.0 (api = 23) environment and a crash occurs (check that the configuration permission has been configured in the AndroidManifest. xml file ). It works normally in the Android4.4 (api = 19) environment. Because there are only two android phones, no other systems before android were attempted. The Code is as follows:
public static void install(Context context, String filePath) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i);}
Solution Process:
Baidu has no fruit, and google has an answer.
Solution:
After android6.0 (api = 23), open the file and let the system determine how to handle it. For detailed solutions, see the following address:
Http://www.jianshu.com/p/d896a09b9aca
Cause analysis:
API <= 22 com.android.packageinstallerAPI >= 23 com.google.android.packageinstaller
Http://stackoverflow.com/questions/32211392/packageinstalleractivity-not-found-on-android-m-developer-preview
However, after "intent. setComponent (comp);" is added to the above code, it will still crash under android6.0.