我想将图像作为位图从一个活动传递到另一个活动。我想知道这样做是否可能。
发送活动
Intent intent = new Intent(getApplicationContext(), BitmapActivity.class);
                Bundle b = new Bundle();
                b.putParcelable("BITMAP", bitmap);
                intent.putExtras(b);
                startActivity(intent);接收活动
Bundle bb = this.getIntent().getExtras();
    b = bb.getParcelable("BITMAP");但是我得到了!绑定器事务失败!错误
发布于 2014-12-06 15:39:06
您可以使用带有静态位图对象的全局类,如下所示:
public class Global {   static Bitmap img; }
在按意图声明活动之前,请将位图分配给此Global class属性:
Global.img = your_bitmap_img;
在开始活动之后,您可以通过以下方法返回位图:
bitmap_in_new_activity = Global.img;
我知道全局变量对调试来说太危险了,但是这种技术可以帮助我们将大数据从一个活动转移到another.The绑定器事务缓冲区,该缓冲区的固定大小是有限的,目前是1Mb,而不管您的设备功能或应用程序如何。
发布于 2014-06-18 12:29:57
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.f1);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
    byte[] food = stream.toByteArray();
    Intent intent = new Intent(MainActivity.this,NoBoringActionBarActivity.class);
    intent.putExtras(bundle);
    intent.putExtra("picture", food);
    startActivity(intent);  发送活动
Bundle extras = getIntent().getExtras();
    byte[] food = extras.getByteArray("picture");
    Bitmap fo = BitmapFactory.decodeByteArray(food, 0, food.length);
    mHeaderLogo = (ImageView) findViewById(R.id.header_logo);
    //ImageView image = (ImageView) findViewById(R.id.header_logo);
    mHeaderLogo.setImageBitmap(fo);   接收活动
别忘了把你的形象画在抽屉里。
https://stackoverflow.com/questions/24285546
复制相似问题