【发布时间】:2015-06-22 02:59:02
【问题描述】:
在我的 Android 应用中,我有一个按钮,单击该按钮会启动我选择的外部应用程序来播放视频(我认为这称为“隐式意图”)。这是我的onCreate 方法中的相关Java 代码。
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener
(
new Button.OnClickListener()
{
public void onClick(View v)
{
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("https://youtu.be/jxoG_Y6dvU8"), "video/*");
startActivity(i);
}
}
);
我预计这会起作用,因为我已经非常密切地遵循教程和 Android 开发人员文档,但是当我在 AVD 中测试我的应用程序时,而不是提示我可以查看我的视频的外部应用程序菜单,应用程序崩溃。
是什么导致我的应用崩溃?
【问题讨论】:
-
请发布您的日志文件!
-
@GaneshThiagarajan Android Studio 新手...我该怎么做?
-
您应该会看到类似 LogCat 的内容。那是我们通常会收到错误代码和消息的地方。
-
这可能与
https://youtu.be/jxoG_Y6dvU8实际上是一个text/html文件有关。
标签: java android android-intent uri avd