【发布时间】:2013-10-27 17:16:05
【问题描述】:
如何意图系统媒体应用程序?
因为我想使用系统媒体应用程序在我的应用程序中播放视频。
我尝试了以下代码,但没有成功。
url = "http://www.ooklnet.com/files/381/381489/video.mp4";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addCategory(Intent.CATEGORY_APP_MUSIC);
startActivity(intent);
但是当我尝试以下代码时,它是成功的,
url = "http://www.ooklnet.com/files/381/381489/video.mp4";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
但是,它需要我打开两个步骤:
第一步是显示可供选择的对话框(Android 系统和浏览器)。
第二步:当我选择Android系统时,显示应用程序可以播放此视频。
我想按“播放”按钮,它将使用系统媒体应用程序运行,
请告诉我怎么做,
UPDATE 收到 CommonWare 的答复后:
我可以使用以下代码准确定位系统媒体应用程序。
// String type = "audio/mpeg4-generic"; // It works for only Mobo Player
String type = "video/mp4"; // It works for all video application
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(Uri.parse(url), type);
startActivity(intent);
我的设备已存在第三媒体应用程序(Mobo Player、MX Player 和 Video), 视频应用是系统媒体应用,所以我们无法在设置中卸载它。
p/s : 我使用的是 Android 2.2.1 版本,
谢谢,
【问题讨论】:
-
错误是什么,请登录cat?
-
引起:android.content.ActivityNotFoundException:没有找到处理意图的活动{act=android.intent.action.VIEW cat=[android.intent.category.LAUNCHER,android.intent.category. APP_MUSIC] dat=ooklnet.com/files/381/381489/video.mp4 }
标签: android android-intent media-player media intentfilter