是在那里得到uri的位图与保存到SD卡?

我做了一个应用程序,允许用户使用Android意图共享一个图像,但如何得到这个uri

与一个位图需要保存到SD卡我

我用这个代码工作正常,但我不需要将此位图保存到SD卡

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卡

Solutions Collecting From Web of "是在那里得到uri的位图与保存到SD卡?"

尝试这个:

 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 } 

试试这个方法

 protected void tryToShareImage(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(); } startActivity(Intent.createChooser(intent, "Share using...")); } 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); } 

之后,您可以使用File.delete()删除文件