路过形象PutExtra在Android中 [英] Passing the Image in PutExtra in Android

查看:103
本文介绍了路过形象PutExtra在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我已经设置按钮在PutExtra()意图对象到另一个类的背景图像。

I want to pass the Background Image that I have set to Button in PutExtra() with intent object into another Class.

能否有人知道如何做到这一点?

Can anybody know how to do that ?

谢谢
davidbrown

Thanks davidbrown

推荐答案

试试这个...

首先得到图像中的位图。

first get image in bitmap.

Bitmap tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore);

CONVER它字节数组。

Conver it in byte array.

 ByteArrayOutputStream stream = new ByteArrayOutputStream();
      photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
      byte[] byteArray = stream.toByteArray();

      Bundle b = new Bundle();
      b.putByteArray("camara",byteArray);

      Intent intent3 = new Intent(this,Second.class);
      intent3.putExtras(b);
      startActivity(intent3);          

这篇关于路过形象PutExtra在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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