how do you pass images (bitmaps) between android activities using bundles?

后端 未结 9 1197
自闭症患者
自闭症患者 2020-11-22 09:56

Suppose I have an activity to select an image from the gallery, and retrieve it as a BitMap, just like the example: here

Now, I want to pass this BitMap to be used i

9条回答
  •  悲&欢浪女
    2020-11-22 10:39

    You can pass image in short without using bundle like this This is the code of sender .class file

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher;
    Intent intent = new Intent();
    Intent.setClass(.this, 

    and this is receiver class file code.

    Bitmap bitmap = (Bitmap)this.getIntent().getParcelableExtra("Bitmap");
    ImageView viewBitmap = (ImageView)findViewById(R.id.bitmapview);
    viewBitmap.setImageBitmap(bitmap);
    

    No need to compress. that's it

提交回复
热议问题