Intent intent1 = new Intent( android.provider.MediaStore.INTENT_ACTION_MUSIC_PLAYER) .setData(selectedImageUri);
我想使用 android 默认媒体播放器播放媒体文件,但它在显示的设备上不起作用
ActivityNotFoundException
.谁能帮我纠正一下。我被困在这里了
最佳答案
String extension = MimeTypeMap
.getFileExtensionFromUrl(selectedImagePath);
String mimeType = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(extension);
Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
mediaIntent.setDataAndType(Uri.parse(selectedImagePath),
mimeType);
startActivity(mediaIntent);
我使用了这段代码并得到了我的输出。
关于android - 媒体播放器异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8905855/