Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

android - FAILED BINDER TRANSACTION while passing Bitmap from one activity to another

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.

Sending Activity

Intent intent = new Intent(getApplicationContext(), BitmapActivity.class);
                Bundle b = new Bundle();
                b.putParcelable("BITMAP", bitmap);
                intent.putExtras(b);
                startActivity(intent);

Receiving Activity

Bundle bb = this.getIntent().getExtras();
    b = bb.getParcelable("BITMAP");

But i am getting !!! FAILED BINDER TRANSACTION !!! Error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

public class Global { static Bitmap img; }

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;

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...