如何将位图从一个活动传递到另一个活动 [英] How to pass bitmap from one activity to another

查看:25
本文介绍了如何将位图从一个活动传递到另一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ActivityA 中有位图,我想将位图从这里传递给 ActivityB,我用谷歌搜索了这个.当我使用这个

i have bitmap in ActivityA i want to pass the bitmap from here to ActivityB, i googled for this. when i use this

Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("BitmapImage", bitmap);

为了得到

Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");

我收到此错误!!!绑定交易失败!!! .我该如何解决这个问题.

i am getting this error !!! FAILED BINDER TRANSACTION !!! . how can i solve this problem.

推荐答案

您的代码对于将位图放入额外内容是正确的,并且对于小图像的我来说效果很好.但是似乎Parcelable extra 的大小是有限制的.请参阅 http://groups.google.com/group/android-developers/browse_thread/thread/7322a84adcfee567?pli=1.

Your code is correct for putting bitmaps into the extras and works fine for me with small images. But it seems that there is a limit for the size of the Parcelable extra. See http://groups.google.com/group/android-developers/browse_thread/thread/7322a84adcfee567?pli=1.

您可能希望先存储图像,然后再将 URI 移交给存储位置.

You might want to store the image first and only hand over the URI to the store location.

按照 udaykiran 的建议对位图使用公共静态字段违反了许多面向对象的原则,我什至不知道从哪里开始.

Using a public static field for the bitmap as suggested by udaykiran violates so many OO principles I don't even know where to start.

这篇关于如何将位图从一个活动传递到另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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