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

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

问题描述

在我的活动,我创建了一个位图对象,然后我需要推出另一活动, 我怎样才能通过这个位图对象从子活动(的其中一个将要推出的)?

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)?

推荐答案

位图工具 Parcelable ,所以你可以总是通过它的意图:

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

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

和检索它的另一端:

意向意图= getIntent();
   位图位=(位图)intent.getParcelableExtra(BitmapImage的);

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

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

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