我尝试从URl安装apk,这是我的代码:
Intent promptInstall = new Intent(android.content.Intent.ACTION_VIEW); promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); promptInstall.setDataAndType(Uri.parse("http://10.0.2.2:8081/MyAPPStore/apk/Teflouki.apk"),"application/vnd.android.package-archive" ); startActivity(promptInstall);
但我有这个问题:
05-10 15:09:29.511: ERROR/AndroidRuntime(1668): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://10.0.2.2:8081/MyAPPStore/apk/Teflouki.apk typ=application/vnd.android.package-archive flg=0x10000000 }
提前致谢
解决方法
您应该在安装之前在存储中下载xxx.apk:
Intent promptInstall = new Intent(android.content.Intent.ACTION_VIEW); promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); promptInstall.setDataAndType(Uri.parse("storage/xxx.apk"),"application/vnd.android.package-archive" ); startActivity(promptInstall);