Android : Play/open Youtube video



// your video id
// for instance a video link: http://www.youtube.com/watch?v=Q9hF0j9G8_M
String videoId = "Q9hF0j9G8_M"; 

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId));
intent.putExtra("VIDEO_ID", videoId);
startActivity(intent);

This will open the video using Youtube app (if exist in your device)
otherwise, it will open the video in browser app

Advertisements

2 thoughts on “Android : Play/open Youtube video

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s