如何启动ACTION_SEND意图时,附加的位图 [英] How to attach a Bitmap when launching ACTION_SEND intent
问题描述
我有这个code:
意向意图=新的意图();
intent.setAction(Intent.ACTION_SEND);
startActivity(意向);
这将成功地推出一个消息应用程序在Android上。
但我怎么能启动的意图时,附加的位图对象吗?
我读<一href="http://developer.android.com/reference/Android/content/Intent.html">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);
其中位图是必须存放在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.
这篇关于如何启动ACTION_SEND意图时,附加的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!