失败粘结剂交易,而通过位图从一个活动到另一个 [英] FAILED BINDER TRANSACTION while passing Bitmap from one activity to another

查看:181
本文介绍了失败粘结剂交易,而通过位图从一个活动到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个图像作为位图从一个活动到另一个。我想知道是否有可能做这样的。

I want to pass a image as a bitmap from one activity to another. And i want to know whether it is possible to do like that.

发送活动

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

但我正在逐渐的!失败粘结剂交易!错误

推荐答案

您可以在其中使用全局类的静态位图对象,是这样的:

You can use a global class with a static bitmap object in it, something like this:

公共类全局{   静态位图IMG; }

public class Global { static Bitmap img; }

在述明意图的活动,赋予您的位图到这个全球class属性:

Before stating the activity by intent, assign your bitmap to this Global class attribute:

Global.img = your_bitmap_img;

在开始你的活动,你可以回到你的位图是:

After starting your activity, you can get back your bitmap by:

bitmap_in_new_activity = Global.img;

我知道全局变量进行调试太危险了,但这种技术能帮助我们从一个活动传输大量数据another.The粘合剂事务缓冲区具有有限的固定的大小,目前为1Mb不管你的设备的功能或应用程序。

I know global variables are too dangerous for debugging but this technique helps us to transfer large data from one activity to another.The binder transaction buffer has a limited fixed size, currently 1Mb regardless of your device capabilities or your app.

这篇关于失败粘结剂交易,而通过位图从一个活动到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆