路过形象PutExtra在Android中形象、PutExtra、Android

2023-09-06 15:40:00 作者:喝着脉动割动脉

我想通过我已经设置按钮在PutExtra()意图对象到另一个类的背景图像。

I want to pass the Background Image that I have set to Button in PutExtra() with intent object into another Class.

能否有人知道如何做到这一点?

Can anybody know how to do that ?

谢谢davidbrown

Thanks davidbrown

推荐答案

试试这个...

首先得到图像中的位图。

first get image in bitmap.

Bitmap tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore);

CONVER它字节数组。

Conver it in byte array.

 ByteArrayOutputStream stream = new ByteArrayOutputStream();
      photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
      byte[] byteArray = stream.toByteArray();

      Bundle b = new Bundle();
      b.putByteArray("camara",byteArray);

      Intent intent3 = new Intent(this,Second.class);
      intent3.putExtras(b);
      startActivity(intent3);