tba tba - 8 months ago 49
Android Question

Force video to open in Youtube app on Android

I have a mobile website that links to a youtube video. On Android, clicking on this link brings up a dialog asking the user to "Complete action using" their browser or the Youtube app.

Is there a way to bypass this screen and just play the video in the Youtube app? (For example with a youtube:// URL.)


Tim Tim

Here's how you can do that:

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

The id is the identifier after the questionmark in the url. For example: youtube.com/watch?v=ID

Another way is:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");