如何将 Bitmap 对象从一个活动传递到另一个活动 [英] How can I pass a Bitmap object from one activity to another

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

问题描述

在我的活动中,我创建了一个 Bitmap 对象,然后我需要启动另一个 Activity,如何从子活动(将要启动的活动)传递这个 Bitmap 对象?

In my activity, I create a Bitmap object and then I need to launch another Activity, How can I pass this Bitmap object from the sub-activity (the one which is going to be launched)?

推荐答案

Bitmap 实现了 Parcelable,所以你总是可以带着意图传递它:

Bitmap implements Parcelable, so you could always pass it with the intent:

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

并在另一端检索它:

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

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

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