开发者

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜