2013-07-16 217 views
2

我的SD卡中沒有AMR文件。我想用默認的安卓音樂播放器播放這些amr文件。 TODO這一點,我想下面的代碼:Android使用默認音樂播放AMR文件音樂播放器

 Uri myUri = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath() + "/myfiles/filename.amr"); 
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW); 
    intent.setDataAndType(myUri, "audio/*"); 
    startActivity(intent); 

和我的堆棧跟蹤:

07-16 15:23:47.284: D/Instrumentation(32496): checkStartActivityResult :Intent { act=android.intent.action.VIEW dat=/storage/emulated/0/myfiles/filename.amr typ=audio/* }
07-16 15:23:47.284: D/Instrumentation(32496): checkStartActivityResult inent is instance of inent: 07-16 15:23:47.284: D/AndroidRuntime(32496): Shutting down VM
07-16 15:23:47.284: W/dalvikvm(32496): threadid=1: thread exiting with uncaught exception (group=0x414feac8)
07-16 15:23:47.304: E/AndroidRuntime(32496): FATAL EXCEPTION: main
07-16 15:23:47.304: E/AndroidRuntime(32496): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/storage/emulated/0/myfiles/filename.amr typ=audio/* }
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1659)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1434)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Activity.startActivityForResult(Activity.java:3430)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Activity.startActivityForResult(Activity.java:3391)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Activity.startActivity(Activity.java:3626)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.Activity.startActivity(Activity.java:3594) 07-16 15:23:47.304: E/AndroidRuntime(32496): at com.example.ui.MainActivity.onItemClick(MainActivity.java:85)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.widget.AdapterView.performItemClick(AdapterView.java:301)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.widget.AbsListView.performItemClick(AbsListView.java:1502)
07-16 15:23:47.304: E/AndroidRuntime(32496): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3250) 07-16 15:23:47.304: E/AndroidRuntime(32496): at android.widget.AbsListView$1.run(AbsListView.java:4299) 07-16 15:23:47.304: E/AndroidRuntime(32496): at android.os.Handler.handleCallback(Handler.java:725) 07-16 15:23:47.304: E/AndroidRuntime(32496): at android.os.Handler.dispatchMessage(Handler.java:92) 07-16 15:23:47.304: E/AndroidRuntime(32496): at android.os.Looper.loop(Looper.java:137) 07-16 15:23:47.304: E/AndroidRuntime(32496): at android.app.ActivityThread.main(ActivityThread.java:5227)
07-16 15:23:47.304: E/AndroidRuntime(32496): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 15:23:47.304: E/AndroidRuntime(32496): at java.lang.reflect.Method.invoke(Method.java:511) 07-16 15:23:47.304: E/AndroidRuntime(32496): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 07-16 15:23:47.304: E/AndroidRuntime(32496): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 07-16 15:23:47.304: E/AndroidRuntime(32496): at dalvik.system.NativeStart.main(Native Method)

我怎麼能做到這一點? 當這個amr在文件管理器打開時,它顯示一個對話框,選擇可用的音樂播放器並開始播放。我想實現的目標。

my target to achieve to get this pop up in my app

+0

任何意向和行動所需的類? – NitZRobotKoder

+0

@NitZRobotKoder我跟着這個鏈接http://stackoverflow.com/questions/6265893/how-to-start-the-default-music-player-from-my-app – Meher

回答