我正在尝试以编程方式打开下载的文件夹。但是,我不断得到ActivityNotFoundException
。我在 StackOverflow 上看到了各种关于此的问题,尝试了其中的大部分,但到目前为止没有任何效果。这是我下面的代码
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(downloadDirectoryPath));
startActivity(intent);
AndroidManifest.xml - 相关代码
<activity
android:name="com.xx.xxx.videowebview.VideoWebViewActivity"
android:configChanges="orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:theme="@style/custom_theme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
我想我也已经在清单中设置了所需的东西,但是,我仍然不断收到异常。
我有一个下载按钮VideoWebViewActivity
,单击时会下载文件,然后必须打开download
设备上的文件夹。如上所述,将类别设置为 DEFAULT 是否正确?还是我应该使用新活动(我真的不需要任何其他活动,所以我应该使用虚拟活动吗?听起来不对……)?
这是我的LogCat ...
03-28 15:17:37.349: E/AndroidRuntime(15791): FATAL EXCEPTION: main
03-28 15:17:37.349: E/AndroidRuntime(15791): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/mnt/sdcard/download/ }
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.app.Activity.startActivityForResult(Activity.java:2827)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.app.Activity.startActivity(Activity.java:2933)
03-28 15:17:37.349: E/AndroidRuntime(15791): at com.xx.xxx.videowebview.VideoWebViewActivity$DownloadFile.onPostExecute(VideoWebViewActivity.java:442)
03-28 15:17:37.349: E/AndroidRuntime(15791): at com.xx.xxx.videowebview.VideoWebViewActivity$DownloadFile.onPostExecute(VideoWebViewActivity.java:1)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.os.AsyncTask.finish(AsyncTask.java:417)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.os.Handler.dispatchMessage(Handler.java:99)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.os.Looper.loop(Looper.java:130)
03-28 15:17:37.349: E/AndroidRuntime(15791): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-28 15:17:37.349: E/AndroidRuntime(15791): at java.lang.reflect.Method.invokeNative(Native Method)
03-28 15:17:37.349: E/AndroidRuntime(15791): at java.lang.reflect.Method.invoke(Method.java:507)
03-28 15:17:37.349: E/AndroidRuntime(15791): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
03-28 15:17:37.349: E/AndroidRuntime(15791): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
03-28 15:17:37.349: E/AndroidRuntime(15791): at dalvik.system.NativeStart.main(Native Method)