如何启动ACTION_SEND意图时,附加的位图位图、意图、ACTION_SEND

由网友(马蹄踏碎落叶)分享简介:我有这个code:意向意图=新的意图();intent.setAction(Intent.ACTION_SEND);startActivity(意向);这将成功地推出一个消息应用程序在Android上。 但我怎么能启动的意图时,附加的位图对象吗? 我读http://developer.android.com/refer...

我有这个code:

 意向意图=新的意图();
 intent.setAction(Intent.ACTION_SEND);
 startActivity(意向);
 

这将成功地推出一个消息应用程序在Android上。

但我怎么能启动的意图时,附加的位图对象吗?

我读http://developer.android.com/reference/Android/content/Intent.html, 衣柜里的事情,我需要的是EXTRA_STREAM,像这样的:

  

intent2.putExtra(Intent.EXTRA_STREAM,_uri);

不过我的情况,我有位图对象,位图不是一个URI的参考。

请告诉我该怎么做才能附加Bitmap对象?

解决方案

 字符串pathofBmp = Images.Media.insertImage(getContentResolver(),位图,称号,空);
    乌里bmpUri = Uri.parse(pathofBmp);
    最终意图emailIntent1 =新的意图(android.content.Intent.ACTION_SEND);
    emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent1.putExtra(Intent.EXTRA_STREAM,bmpUri);
    emailIntent1.setType(图像/ PNG);
 
action的东西怎么打开

其中位图是必须存放在SD卡的位图对象。然后使用该URI发送图像。

I have this code:

 Intent intent = new Intent(); 
 intent.setAction(Intent.ACTION_SEND); 
 startActivity(intent); 

Which will successfully launch a Messaging App on Android.

But how can I attach a Bitmap object when launching the intent?

I have read http://developer.android.com/reference/Android/content/Intent.html, the closet thing to what I need is EXTRA_STREAM, like this:

intent2.putExtra(Intent.EXTRA_STREAM, _uri);

But my case, I have a reference of Bitmap object, not an URI of a Bitmap.

Please tell me what to do to attach a Bitmap object?

解决方案

    String pathofBmp = Images.Media.insertImage(getContentResolver(), bitmap,"title", null);
    Uri bmpUri = Uri.parse(pathofBmp);
    final Intent emailIntent1 = new Intent(     android.content.Intent.ACTION_SEND);
    emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
    emailIntent1.setType("image/png");

Where bitmap is your bitmap object which must be store in SD Card. and then use that Uri for sending image.

阅读全文

相关推荐

最新文章