有没有去得到与出它保存位图的URI到SD卡? [英] is there away to get uri of bitmap with out save it to sdcard?
本文介绍了有没有去得到与出它保存位图的URI到SD卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做一个应用程序,允许用户分享图片采用了android意图,但如何获得这个URI
i make an app that allow user to share an image using android intent but how to get that uri of
与出位图需要将其保存到SD卡我
a bitmap with out need to save it to sdcard i
我已经使用这个code,它工作正常,但我不需要保存此位图到SD卡
i have used this code that works fine but i dont need to save this bitmap to sdcard
private Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "title", null);
return Uri.parse(path);
}
我需要得到该URI与出保存位图到SD卡
i need to get that uri with out save that bitmap to sdcard
推荐答案
试试这个:
protected void ShareImage(Intent intent) {
try {
URL url = new URL(mImageUrl);
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
intent.putExtra(Intent.EXTRA_STREAM, getImageUri(mActivity, image));
} catch (Exception e) {
e.printStackTrace();
}
startActivityForResult(Intent.createChooser(intent, 1001));
}
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
public void onActivityResult(int requestCode, int resultCode, Intent data){
//check for result is OK and then check for your requestCode(1001) and then delete the file
}
这篇关于有没有去得到与出它保存位图的URI到SD卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文