Araib karim
Araib karim

Reputation: 421

Android Intent.ACTION_SEND Youtube

I want to use my application to upload videos on YouTube. I'm using this code:

uploadIntent.setDataAndType(Uri.fromFile(f), "video/quicktime");
startActivity(Intent.createChooser(uploadIntent, "Upload"));

but it also shows me options for bluetooth, gmail etc. when I want to it to display only the YouTube option. How can I display only the YouTube option?

Upvotes: 0

Views: 1025

Answers (1)

kabuko
kabuko

Reputation: 36302

I had misunderstood what you were asking. It seems that you have the upload working but want to restrict it to only YouTube. To achieve this, you should not use Intent.createChooser since there's no point in choosing if you only want to display one option. Instead, you can use Intent.setClassName to specify the package and class for YouTube.

You can discover the correct values by simply examining the Intents passed back in your current code when you select YouTube. You'll want to set the return value of Intent.createChooser from PackageManger.queryIntentActivites to a local variable, set a breakpoint in the line after and examine the contents of the YouTube Intent when it breaks.

Upvotes: 2

Related Questions