【问题标题】:ActivityNotFound Exception when requesting App download on Emulator在模拟器上请求应用程序下载时出现 ActivityNotFound 异常
【发布时间】:2013-02-05 11:20:30
【问题描述】:

我尝试使用 Intent 下载 apk 文件

 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)

【问题讨论】:

  • 请添加更多信息。您从哪里下载?你是在提取apk形式的电话吗?或者你有自己的服务器?
  • 你在模拟器上测试吗?
  • @Mr.Me 是在模拟器操作系统 4.1 版中

标签: android android-emulator


【解决方案1】:

系统安装程序只能打开本地文件系统上的 APK 文件。您可以自己下载 APK 然后安装它,或者您可以使用相同的意图而不使用 mime 类型使用默认浏览器下载它(然后用户必须单击下载的文件来安装它)。

【讨论】:

  • 我不想安装应用程序。我只需要下载应用程序并将其存储在其他地方或将其存储在 sdcard 的下载文件夹中
  • 那么就用下面这行来下载:intent.setData(uri);
【解决方案2】:

好的,您收到 ActivityNotFoundException 的异常是因为您的 android 模拟器上没有安装 Google Play。

在任何实际设备上测试它应该没有任何问题。

有关Google Play On Emulator的更多信息,请访问此链接Google Play On Emulator

【讨论】:

    猜你喜欢
    • 2012-06-10
    • 1970-01-01
    • 2013-11-08
    • 2020-10-22
    • 2023-03-20
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    • 2015-12-08
    相关资源
    最近更新 更多