How can I transform a Bitmap into a Uri?

前端 未结 6 2079
一向
一向 2020-12-30 19:34

I\'m trying to share images with Facebook, twitter, etc using SHARE INTENT from Android.

I found code to send a image to the share intent, but this code

6条回答
  •  时光说笑
    2020-12-30 19:58

    Here is the Colin's Blog who suggest the simple method to convert bitmap to Uri Click here

    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);
    }
    

提交回复
热议问题