将图像从一项活动传递到其他活动
我正在尝试传递来自移动媒体的图像。我能够从媒体中获取图像,但我需要将该图像发送到下一个活动。我该如何发送?将图像从一项活动传递到其他活动
任何人都可以给我的示例代码,使图像base64字符串,反之亦然在android中。
请帮我我坚持这两天...提前
谢谢...
SITA。
该第一U保存图像中的一个文件,并在其他活动采取图像从该文件
(-1)一个开销。有一个在活动之间传递数据的内置机制。看到我的答案。 – 2011-02-04 07:24:31
@Vlad不是真的[阅读此](http://groups.google.com/group/android-developers/browse_thread/thread/11f252430b34f4b8/49cfea00e229d537?show_docid=49cfea00e229d537)。虽然它可能不被推荐。这一切都取决于图像的大小。 – Reno 2011-02-04 07:49:43
要在两个活动之间传递数据:
bytes[] imgs = ... // your image
Intent intent = new Intent(this, YourActivity.class);
intent.putExtra("img", imgs);
startActivity(intent);
然后在YourActivity:
bytes[] receiver = getIntent().getExtra("imgs");
您可以使用诸如:
我假设:发送图像ACTIV从A
Actvity两者均B:
Intent i = new Intent(A.this,B.class);
i.putExtra("image_send",bitmap)
//with bitmap is image that you want to send.
startActivity(i);
活性B:
//receive image
Bitmap b = (Bitmap) getIntent().ParcelableExtra("image_send")
为假设SITA。缓存图像并将文件名传递给下一个活动太难了吗?这比使用putParcelable()更有效率。 – Reno 2011-02-04 07:24:29