1

デフォルトの音楽プレーヤーでいくつかのオーディオ ファイルを再生したいと考えています。この投稿で述べたように、次のコードを試しました。

    Intent intent = new Intent();  
    ComponentName comp = new ComponentName("com.android.music", "com.android.music.MediaPlaybackActivity");
    intent.setComponent(comp);
    intent.setAction(android.content.Intent.ACTION_VIEW);  
    File file = new File(songPath.toString());  
    intent.setDataAndType(Uri.fromFile(file), "audio/*");  
    startActivity(intent);

しかし、次のログで ActivityNotFound Exception が発生しています。

07-12 11:28:49.575: E/AndroidRuntime(22700): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jusplay/com.example.jusplay.playdb}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/com.android.music.MediaPlaybackActivity}; have you declared this activity in your AndroidManifest.xml?
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.os.Looper.loop(Looper.java:130)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread.main(ActivityThread.java:3701)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at java.lang.reflect.Method.invokeNative(Native Method)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at java.lang.reflect.Method.invoke(Method.java:507)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at dalvik.system.NativeStart.main(Native Method)
07-12 11:28:49.575: E/AndroidRuntime(22700): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/com.android.music.MediaPlaybackActivity}; have you declared this activity in your AndroidManifest.xml?
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.Activity.startActivityForResult(Activity.java:2827)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.Activity.startActivity(Activity.java:2933)
07-12 11:28:49.575: E/AndroidRuntime(22700):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)

なぜこのクラッシュが起こっているのかわかりません!!

4

0 に答える 0