问题
Possible Duplicate:
Android YouTube app Play Video Intent
I wanted to know how to open Youtube App on Android directly using intent.
What i have:
@Override
public void onClick(View v) {
String video_path = "http://www.youtube.com/user/videoslusofona";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(video_path));
startActivity(intent);
}
What i don't want is for Android to ask me what App i want to open, i want to open Youtube App directly on click.
Thanks for your time
回答1:
you can try:
String videoId = "VideoIDGoesHere";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId));
intent.putExtra("VIDEO_ID", videoId);
startActivity(intent);
You might want to look at using
Intent lVideoIntent = new Intent(null, Uri.parse("ytpl://"+YOUTUBE_PLAYLIST_ID), this, OpenYouTubePlayerActivity.class);
startActivity(lVideoIntent);
from the wiki, you'll need to have the playlist id but it seems like this should work.
来源:https://stackoverflow.com/questions/13825972/how-to-open-youtube-app-directly-via-intent