2013-02-05 48 views
-1

應用程序下載,當我試圖使用它來下載apk文件意圖ActivityNotFound異常請求在模擬器

Intent intent = new Intent(Intent.ACTION_VIEW);   
intent.setDataAndType(uri,"application/vnd.android.package-archive"); 
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
startActivity(intent); 

我得到一個異常

02-05 16:48:35.207: E/AndroidRuntime(2719): FATAL EXCEPTION: main 
02-05 16:48:35.207: E/AndroidRuntime(2719): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://192.168.102.157:8080/ApkDownload/Download typ=application/vnd.android.package-archive } 
02-05 16:48:35.207: E/AndroidRuntime(2719):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545) 
02-05 16:48:35.207: E/AndroidRuntime(2719):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416) 
+0

請加一些更多的信息.​​.你從哪兒下載呢?你是否解壓apk格式電話?或者你有自己的服務器? – drulabs

+0

@KKD來自服務器 – Bucks

+0

您是在模擬器上測試嗎? –

回答

0

出現在本地文件系統安裝只能打開APK文件系統。您可以自己下載APK並安裝它,也可以使用默認類型的相同意圖使用默認瀏覽器下載(然後用戶將不得不點擊下載的文件進行安裝)。

+0

我不想安裝應用程序。我需要下載應用程序並將其存儲在其他地方或將其存儲在sdcard的下載文件夾中 – Bucks

+0

然後,只需使用以下行即可下載它:intent.setData(uri); – XGouchet

0

好的,你得到的例外ActivityNotFoundException是因爲你的android模擬器沒有安裝Google Play。

在任何實際設備上測試它都不會有任何問題。

欲瞭解更多信息有關谷歌玩模擬器請訪問此鏈接Google Play On Emulator