Question

Good morning,

I am using the following code so that my app shows up when the user chooses a Share option on an image:

 <intent-filter>
  <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="image/*" />                 
 </intent-filter>

I am unable to figure out how to get the image or a Uri to the image when the user chooses my app.

Any help is appreciated.

Was it helpful?

Solution

Here's the code you need. Call this from your Activity.

Intent launchIntent = getIntent();
Bundle extras = launchIntent.getExtras();
if (extras.containsKey(Intent.EXTRA_STREAM)) {
      final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top