YouTube的視頻,你可以打開YouTube應用中的視頻,如果不是instaled YouTube應用,你可以在瀏覽器中打開鏈接的YouTube
if(isAppInstalled("com.google.android.youtube", getApplicationContext())) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + "WvYsIGYsgJQ"));
intent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(intent);
}
else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=WvYsIGYsgJQ")));
}
public static boolean isAppInstalled(String uri, Context context) {
PackageManager pm = context.getPackageManager();
boolean installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
installed = true;
} catch (PackageManager.NameNotFoundException e) {
installed = false;
}
return installed;
}
「我想,以確保從現在年「你甚至不能確定Android仍然存在。嘗試讓您的應用程序在沒有閃光燈的設備上正常工作,這是您現在可以做的最好的。 – zapl
我相信谷歌知道它,並會照顧這一點。谷歌將啓用其瀏覽器播放Flash之前播放YouTube視頻。 – wtsang02