我使用以下代码在支持它的活动(通常是浏览器)中加载YouTube视频:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + videoId));
context.startActivity(i);我收到了这个匿名跟踪,我不知道这是怎么发生的。这是否意味着设备不知道它需要使用什么活动来处理'http‘协议?(即没有浏览器?)
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://www.youtube.com/watch?v=xxxxxx }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
at android.app.Activity.startActivityForResult(Activity.java:3190)
at android.app.Activity.startActivity(Activity.java:3297)
at com.sprogcoder.basetube.d.c.a(Unknown Source)
at com.sprogcoder.basetube.f.b.onItemClick(Unknown Source)
at android.widget.AdapterView.performItemClick(AdapterView.java:292)
at android.widget.Gallery.onSingleTapUp(Gallery.java:960)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:568)
at android.widget.Gallery.onTouchEvent(Gallery.java:937)
at android.view.View.dispatchTouchEvent(View.java:5546)谢谢!
发布于 2012-08-02 04:42:23
如果添加了有效的视频Id怎么办?比如"AOsgv_X_cV8“
String videoId = "AOsgv_X_cV8";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + videoId));
context.startActivity(i);但我认为你正试图在模拟器上做这件事,这就是你得到这个错误信息的原因。使用youtube应用程序。
try {
url="vnd.youtube:"+videoId;
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch(ActivityNotFoundExcepiton e) {
Toast.makeText(context, "Plase install Youtube app to see this video", Toast.LENGTH_LONG).show();
}发布于 2012-08-02 04:43:21
将您的URI修改为http://www.youtube.com/v/{VIDEOID}
https://stackoverflow.com/questions/11767172
复制相似问题