Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

intent to youtube app profile/channel

I am able to intent to the youtube app to view a video easily enough, but how about getting to a 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 begin here? Is there a specific Uri to parse? I've tried scouring the internet of course and I'm coming up dry for answers. Is it even possible in the first place?

Thanks guys!

like image 896
RedactedProfile Avatar asked Jan 12 '12 19:01

RedactedProfile


2 Answers

By doing the following ,one can launch Youtube App to display 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 in order to display channel,keep in mind to give url in format http://www.youtube.com/user/channelName

like image 131
laaptu Avatar answered Oct 17 '22 09:10

laaptu


As of now, there is no specific URI scheme for channels that would trigger the YouTube application directly. The vnd.youtube scheme is defined only for the activity that plays a single video. So, you have to specify the canonical YouTube URL for the channel page, and typically let the user pass through the application chooser dialog - assuming that the device has the YouTube application installed, the dialog would display at least two entries, the second being for the browser.

like image 30
Giulio Piancastelli Avatar answered Oct 17 '22 10:10

Giulio Piancastelli