Android YouTube app Play Video Intent

0 votes
I m working on a app where you can download YouTube videos for android. Now, I want if you play a video in the YouTube  app you can download it too. To do this, I need to know the Intent that the YouTube  app puts out in order to play the YouTube app.
my question is:
1. Can I download the YouTube app for my emulator, or...
2. What is the intent used when the user selects a video for playback.
Jun 2 in Others by polo
• 1,500 points
25 views

1 answer to this question.

0 votes

The best way to run videos on a different app is by first trying to resolve the package, so something like this:

public void playVideo(String key){

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + key));

    // Check if the youtube app exists on the device
    if (intent.resolveActivity(getPackageManager()) == null) {
        // If the youtube app doesn't exist, then use the browser
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://www.youtube.com/watch?v=" + key));
    }

    startActivity(intent);
}
answered Jun 6 by nisha
• 2,160 points

Related Questions In Others

0 votes
0 answers

Can you delete android play store app and use the package name?

I have an app that's currently on ...READ MORE

Jun 7 in Others by polo
• 1,500 points
9 views
0 votes
2 answers

Code for download video from Youtube on Java, Android

Check the source code (HTML) of YouTube, ...READ MORE

answered Jun 9 in Others by nisha
• 2,160 points
30 views
0 votes
1 answer

How to open the Google Play Store directly from my Android application?

By using developer.andriod.com, one can solve this ...READ MORE

answered Feb 8 in Others by Rahul
• 8,980 points
15 views
0 votes
1 answer

How can I change IP in Android emulator

Here's the six step you need to ...READ MORE

answered Feb 24 in Cyber Security & Ethical Hacking by Edureka
• 8,460 points
446 views
0 votes
1 answer

Launching Google Maps Directions via an intent on Android

We can open Google Maps app using ...READ MORE

answered Jun 1 in Others by nisha
• 2,160 points
24 views
0 votes
1 answer

How to make android phone flashlight blink?

This might be too fast to blink:- String[] ...READ MORE

answered Jun 6 in Others by nisha
• 2,160 points
20 views
0 votes
1 answer

How to open YouTube video link in android app?

The below code will do that: Intent intent ...READ MORE

answered Jun 1 in Others by nisha
• 2,160 points
28 views
0 votes
1 answer

I am not able to Autoplay youTube video in android chrome

It will play if you set it to ...READ MORE

answered Jun 6 in Others by nisha
• 2,160 points
20 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP