Android 6.0 Intent installation apk flash back, androidapk

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.