Question

How can I launch youtube app using intent

         Intent intent = new  Intent(Intent.ACTION_VIEW);

         intent.setPackage("com.google.android.youtube");    
         intent.setData(Uri.parse("https://www.youtube.com/watch?v=3TKSW-VgVyM"));

         startActivity(intent);

The above code plays the video in youtube, but I want to open only youtube app, How Can I achieve this? Thanks in advance

Was it helpful?

Solution

you can open it using the package name com.google.android.youtube

start application knowing package name

Intent.getLaunchIntentForPackage("com.google.android.youtube");

OTHER TIPS

This is the code needed for launching the Youtube app. Using this inside an onclicklistener is probably best.

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.youtube");
startActivity( launchIntent );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top