How do get a reference to the file chosen in a action.SEND
Good morning,开发者_JAVA百科
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.
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);
}
精彩评论