Home > Tricks & Tips > Launch Youtube app to play video

Launch Youtube app to play video


A simple snippet for launching Youtube app to play video.

	// constant value of package & class name of YouTube app
	public static final String YOUTUBE_PACKAGE_NAME = "com.google.android.youtube";
	public static final String YOUTUBE_CLASS_NAME = "com.google.android.youtube.WatchActivity";
	
	/**
	 * Launch Youtube to watch an URL
	 * @param context
	 * @param url
	 */
	public static void launchYoutube(Context context, String url) {
		Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));        
        intent.setClassName(YOUTUBE_PACKAGE_NAME, YOUTUBE_CLASS_NAME);        
        context.startActivity(intent);
	}

Cheers,
Pete Houston

Advertisements
Categories: Tricks & Tips Tags: ,
  1. September 6, 2014 at 12:00 pm

    This paragraph presents clear idea designed for the new users of blogging, that actually how
    to do blogging.

  1. No trackbacks yet.

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

%d bloggers like this: