代码:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("audio/*");
startActivityForResult(intent, 1);
结果:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK typ=audio/* }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1638)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
at android.app.Activity.startActivityForResult(Activity.java:3258)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:854)
at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:889)
at org.test.sample.TestFragment.onClick(TestFragment.java:58)
at android.view.View.performClick(View.java:3538)
at android.view.View$PerformClick.run(View.java:14330)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:4977)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
使用"video/*"
类型& "image/*"
正常工作。
目前我正在使用音频
new Intent(Intent.ACTION_PICK, droid.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
答案 0 :(得分:1)
使用以下
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
答案 1 :(得分:1)
double.TryParse()
答案 2 :(得分:0)
是的,它崩溃了,因为没有活动来处理这样的意图行动,
你究竟想要达到什么目的?此外,您可以使用
检查是否存在可以处理此类意图的活动intent.resolveActivity(pm)