Passing android Bitmap Data within activity using Intent in Android

前端 未结 7 1463
梦如初夏
梦如初夏 2020-11-22 09:36

I hava a Bitmap variable named bmp in Activity1 , and I want to send the bitmap to Activity2

Following is the code I use to pass it with the intent.

7条回答
  •  不思量自难忘°
    2020-11-22 09:52

    Simply we can pass only Uri of the Bitmap instead of passing Bitmap object. If Bitmap object is Big, that will cause memory issue.

    FirstActivity.

    intent.putExtra("uri", Uri);
    

    From SecondActivity we get back bitmap.

    Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),Uri.parse(uri));
    

提交回复
热议问题