尝试播放某些设备上的MP3 ActivityNotFoundException [英] Trying to play mp3 ActivityNotFoundException on certain devices

查看:139
本文介绍了尝试播放某些设备上的MP3 ActivityNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从银河ACE设备越来越崩溃报告试图播放MP3文件。

I'm getting crash reports from a Galaxy Ace device trying to play mp3 files.

来自服务器的音频会经常来的MP3。

The audio from the server will always come as mp3.

下面是我的code:

Intent intentaudio = new Intent();
intentaudio.setAction(Intent.ACTION_VIEW);
intentaudio.setDataAndType(URL_OF_MY_MP3_FILE, "audio/mp3");

下面是例外:

android.content.ActivityNotFoundException: No Activity found to handle Intent {
  act=android.intent.action.VIEW dat=http://mymediaserver.com/8/0_rwtel7ii.mp3 typ=audio/mp3 }

有什么不好呢?所有设备都应该能够在默认情况下播放MP3,不是吗?

What is wrong with that? All devices are supposed to be able to play mp3 by default, no?

推荐答案

显然,一些设备不具有可以处理播放MP3文件的活动。这些设备应该能够播放MP3文件,但没有活动处理的意图。你得写一个自己并设置意图过滤说你的活动可以处理播放MP3。

Apparently some devices don't have an activity that can handle playing mp3 files. Those devices should be able to play mp3 files, but there is no activity to handle the intent. You gotta write one yourself and set the intent-filter to say your activity can handle playing mp3.

试试这个,看看是否有一个音乐播放器。

Try this and see if there is a music player.

Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
startActivity(intent);

这篇关于尝试播放某些设备上的MP3 ActivityNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆