当前位置: 代码迷 >> Android >> Intent 传递数据的有关问题
  详细解决方案

Intent 传递数据的有关问题

热度:1   发布时间:2016-05-01 20:58:57.0
Intent 传递数据的问题
Android自带的Intent可以传递bitmap数据,但好像只能小于40k的。我现在有张大图传递,大概120k,不知道怎么传递到第二个activity中,我试过通过btye,但好像也有大小限制……出现黑屏现状。纠结中……………………


------解决方案--------------------
你的是ics的么?
------解决方案--------------------
不管多大,图片本身就保存在SD中,到时拿来获取就可以了
------解决方案--------------------
ics就是android 4.0,你可以尝试其它方法,Intent来传递图片很吃力!
------解决方案--------------------
定义一个全局变量,第一个activity付给它,第二个activity直接拿来用!!! 用完null掉....
------解决方案--------------------
全局静态变量....
------解决方案--------------------
楼上的方法很直接
 不能用个路径 或者什么的 代替具体的byte值吗

------解决方案--------------------
把获取到的Bitmap存放在一个静态存储区内,然后每次用就调用它。但是要防止内存泄漏的问题。
------解决方案--------------------
class Image implements Serializable{
private String url;
private Bitmap bitmap;
}

传递:
Image image = new Image();
image.seturl(url);
image.setbitmap(bitmap);
intent.putExtra("image", image);

获取
Image image = intent.getSerializableExtra("image");
String url = image.geturl();
Bitmap bitmap =image.getbitmap();
  相关解决方案