YouTube profile / channel intent

I can set up the YouTube app to watch videos quite easily, but how do I access my profile / channel?

public void YouTube(String id) { // Play Youtube Video Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:"+id)); mContext.startActivity(i); } 

I ... just don't know where to really start here? Is there a specific Uri to parse? Of course, I tried the Internet, and I went to dry words. Is this possible in the first place?

Thanks guys!

+6
source share
2 answers

There is currently no specific URI scheme for channels that will launch the YouTube app directly. The vnd.youtube schema vnd.youtube defined only for an activity that plays a single video. Thus, you should specify the canonical YouTube URL for the channel page and, as a rule, allow the user to go through the application selection dialog - provided that the YouTube application is installed on the device, at least two entries will be displayed in the dialog box, the second for the browser.

+1
source

By following these steps, you can launch the Youtube App to display the channel directly.

 Intent intent=null; try { intent =new Intent(Intent.ACTION_VIEW); intent.setPackage("com.google.android.youtube"); intent.setData(Uri.parse(url)); startActivity(intent); } catch (ActivityNotFoundException e) { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } 

And to display a channel, keep in mind to specify a url in the format http://www.youtube.com/user/channelName

+24
source

Source: https://habr.com/ru/post/905852/


All Articles