Reputation: 452
I want my app to be shown in every kind of sharing like plain text, images, videos or any files. I also want to handle them accordingly. How can I do that? I'm completely new with sharing related stuff and I can't find any proper documentation for it.
Upvotes: 0
Views: 689
Reputation: 3217
Add this intent filter for receiving all types of sharing intent.
<activity
android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
And in your receiving activity
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
} else {
Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
}
}
You will get shared text and file Uri using the above code
Upvotes: 4