【发布时间】:2018-07-31 07:56:58
【问题描述】:
我正在尝试使用我应用中的默认音频播放器播放 res/raw 目录中的音频文件。
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(String.format("android.resource://%s/%s/%s",getContext().getPackageName(),"raw","fade")), "audio/*");
startActivity(intent);
但是,每次我遇到异常时:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.example.android.punjabi/raw/fade typ=audio/* launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
我已经尝试了这里提到的方法:
Get URI of .mp3 file stored in res/raw folder in android
它仍然给了我同样的例外。
请帮忙。我不想使用 MediaPlayer 类来播放音频。我想用手机默认的音频播放器播放。
【问题讨论】:
标签: android audio android-intent mp3