How to get the data from “share picture via” dialog on Android?

夙愿已清 提交于 2019-12-29 06:24:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!