开发者

Android how to respond to ACTION_VIEW/ ACTION_SEND?

I just cannot seem to figure this one out: how do I respond to the ACTION_VIEW and ACTION_SEND intents? I have them in my Manifest file (and they appear in the drop down list of apps). What I need to do is respond to these intents开发者_运维知识库 and retrieve a bitmap of the corresponding image.

Right now here is what works:

Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
Bitmap mBitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));

Then I take that uri and fetch a bitmap. However, if I respond when the email app downloads and image getExtras() is null and I get an error.

Basically I need to know what to put in here to fill a variable, mBitmap:

if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_VIEW.equals(action))
{
    Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
    Bitmap mBitmap = (getExtras() == null) ? what goes here :
        BitmapFactory.decodeStream(cr.openInputStream(uri)) 
}


getIntent().getData() will contain the Uri for which the Intent is targeted.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜