2

考虑 a,b,c,d,e 都是不为空的字符串。
我有一个名为data的对象,其中包含图像和 prev_image 的 URL。

有一个名为 Games 的活动,通向“MyActivity”。

我的问题是这样的:
如果我尝试“putextra”两个位图,我最终会进入“游戏”,没有给出错误,没有例外,没有任何东西。如果我注释掉我在包中添加“图像”的行,那么一切正常。但我需要在以后的活动中使用图像。所以我必须把它放在那里。我尝试按比例缩小它,但没有帮助,这似乎不是内存问题,但是......我可能是错的:)

Bitmap temp = BitmapFactory.decodeStream((new URL(data.getString("image"))).openStream());
image = image = Bitmap.createScaledBitmap(image,300,300,true);

temp = BitmapFactory.decodeStream((new URL(data.getString("image"))).openStream());
prev_image = Bitmap.createScaledBitmap(image,300,300,true);

temp.recycle();

Intent intent = new Intent(MyActivity.this,NextActivity.class);
intent.putExtra("a",a);
intent.putExtra("b",b);
intent.putExtra("c",c);
intent.putExtra("d",d);
intent.putExtra("e",e);
intent.putExtra("image",image);
intent.putExtra("prev_image",prev_image);
startActivity(intent);

任何帮助将非常感激。

编辑:

我想我会添加用于我的应用程序的解决方案。
我最终做的是将位图保存为文件,然后将 URI 传递给活动之间的文件,并且只在需要它们的活动中加载位图。
当然,最终会删除文件。

4

1 回答 1

0

可以在意图中发送的数据有一个最大大小。您的位图可能超过它。大约 50Kb

于 2012-12-09T17:46:04.140 回答