星空网 > 软件开发 > Java

android 6.0 Intent 安装apk闪退

需求描述:

利用android系统自带的DownloadManager下载apk文件,并且打开安装界面。
问题描述:
关于DownloadManager的使用网上有很多例子,在此不啰嗦。下载完成之后在android6.0(api=23)环境下打开安装界面出现闪退(确认已经在AndroidManifest.
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);}

解决过程:

百度一番无果,google一番有了答案。

解决方案:

android6.0(api=23)以后直接打开文件,让系统去判断如何处理。详细解决方案见如下地址:

http://www.jianshu.com/p/d896a09b9aca

原因分析:

API <= 22 com.android.packageinstallerAPI >= 23 com.google.android.packageinstaller

http://stackoverflow.com/questions/32211392/packageinstalleractivity-not-found-on-android-m-developer-preview

但是我在上面的代码中加入“intent.setComponent(comp);”之后 在android6.0下面依然闪退。




原标题:android 6.0 Intent 安装apk闪退

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流