Reputation: 65
I already inserted this in manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="www.youtube.com" android:mimeType="text/*" />
</intent-filter>
But I couldn't know how Can I get the Link in my Activity
Upvotes: 1
Views: 445
Reputation: 1220
When you add that intent filter you are allowing your app to be launched by youtube, so you need to check if your app was actually launched by youtube or not.
You can do this by first getting the intent and then getting the action of the intent.
In the onCreate method of your activity use this code:
// getting the intent that started your app
Intent intentThatStartedMyApp = getIntent();
// getting the action associated with that intent
String actionOfTheIntentThatStartedMyApp = intentThatStartedMyApp.getAction();
// checking the intent action
if(actionOfTheIntentThatStartedMyApp.equals(Intent.ACTION_SEND)) {
Bundle extras = getIntent().getExtras();
String stringContainingYoutubeLink = extras.getString(Intent.EXTRA_TEXT);
}
Upvotes: 1