Archive

Posts Tagged ‘video’

Launch Youtube app to play video

July 7, 2012 1 comment

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: ,