问题
I've added the intent-filter. And when I tap "share" in the Gallery, it will launch my activity.
<intent-filter>
<action
android:name="android.intent.action.SEND" />
<category
android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="image/*" />
</intent-filter>
But I don't know how to get the correct data from the current intent. Any helps?
EDIT: Sorry, missing "picture" in the question
回答1:
I found the answer.
Uri imageUri = (Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);
回答2:
You can put data in Intent with intent.putExtra(..)
and get data with intent.getXyzExtra(..)
where xyz dependt on the type: can be String, int, array, etc..
Check the Intent docs.
来源:https://stackoverflow.com/questions/4182299/how-to-get-the-data-from-share-picture-via-dialog-on-android