如何将位图转换为Uri? [英] How can i transform a Bitmap into a Uri?
本文介绍了如何将位图转换为Uri?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Android中的SHARE INTENT
与Facebook,Twitter等共享图像.
I'm trying to share images with Facebook, twitter, etc using SHARE INTENT
from Android.
我找到了将图像发送到共享意图的代码,但是此代码需要位图的URI:fullSizeImageUri
I found code to send a image to the share intent, but this code needs the URI of the bitmap: fullSizeImageUri
这是完整的代码:
private void startShareMediaActivity(Bitmap image) {
boolean isVideo=false;
String mimeType="bmp";
Uri fullSizeImageUri=null;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, fullSizeImageUri);
try {
startActivity(Intent.createChooser(intent, (isVideo ? "video" : "image")));
} catch (android.content.ActivityNotFoundException ex) { }
}
请,有人可以帮我将位图转换为Uri吗?
Please, can someone help me to transforma a Bitmap into a Uri?
谢谢
推荐答案
String FILENAME = "image.png";
String PATH = "/mnt/sdcard/"+ FILENAME;
File f = new File(PATH);
Uri yourUri = Uri.fromFile(f);
这篇关于如何将位图转换为Uri?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文