【发布时间】:2014-08-19 07:23:20
【问题描述】:
我正在使用此代码打开 youtube 链接,它以前可以工作,但现在它崩溃了。
Intent intent= new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
intent.setClassName("com.google.android.youtube",
"com.google.android.youtube.PlayerActivity");
这里是logcat
STACK_TRACE=android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.youtube/com.google.android.youtube.WatchActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1636)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1430)
at android.app.Activity.startActivityForResult(Activity.java:3532)
at android.app.Activity.startActivityForResult(Activity.java:3493)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:840)
at android.app.Activity.startActivity(Activity.java:3735)
at android.app.Activity.startActivity(Activity.java:3703)
at com.scutify.CompanyDetailActivity.onItemClick(CompanyDetailActivity.java:366)
at android.widget.AdapterView.performItemClick(AdapterView.java:308)
at android.widget.AbsListView.performItemClick(AbsListView.java:1524)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3531)
at android.widget.AbsListView$3.run(AbsListView.java:4898)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
你能告诉我为什么会崩溃吗? 如何解决? 谢谢
【问题讨论】:
-
您能否发布您的 logCat 或任何可能有助于显示崩溃原因的内容?如果没有这些信息,很难判断发生了什么......
-
是否打算为您的意图设置两个名称(
intent和tab5Intent)? -
@CodeMonkey @Gaetan(对不起,我无法标记你):我已经更新了我的问题
-
如果你有视频的ID,你可以试试
new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)),如果你有完整的链接,你可以试试new Intent(Intent.ACTION_VIEW, Uri.parse(youtubeUrl))。 -
@Gaëtan:我有完整链接,想直接打开 Youtube...你能帮忙吗????