android 之 Intent 传递数据大小有限的问题
2015-07-21 20:17
621 查看
在项目中可能会遇到在Intent中传递 大数据 如图片,但是intent传递的数据是有限的,这是我们就需要用一个对象来 传递这些数据
/** * 处理intent传输数据大小有限问题 * @author lixkb * * @param <T> */ public class IntentCacheHelper<T> { private static IntentCacheHelper<?> instance; private T t; public static <T> IntentCacheHelper<T> getInstance(Class<T> cls) { if(instance == null) { instance = new IntentCacheHelper<T>(); } return (IntentCacheHelper<T>) instance; } public void setObject(T t) { this.t = t; } public T getObject() { return this.t; } public void recycle() { t = null; } }
怎么去用呢,如下
IntentCacheHelper.getInstance(你的bean.class).setObject(bean);
infodetailVO = (InfoDetailPicVO)IntentCacheHelper.getInstance(InfoDetailPicVO.class).getObject(); IntentCacheHelper.getInstance(InfoDetailPicVO.class).recycle();
相关文章推荐
- Android 异步加载
- [Android]自定义ListView:上拉加载更多
- Android ExpandMenu 多级菜单
- AndroidAnnotations库的使用
- Android+OpenCV上手程序
- android studio乱码解决方案
- android开发-简单基础学习
- android遮挡系统拨号界面 类似360来电显示的那个绿色 页面
- Android Toast几种用法
- Android浮动小球与开机自启动
- Android 安卓点击运行后 出错
- Exploring the world of Android :: Part 2
- Android通知的基本用法
- Exploring the world of Android :: Part 1
- android studio gradle download 无反应
- Android设计模式之美---Factory Method
- Android Wear(手表)开发 - 学习指南
- Android--单元测试案例
- 未解——AndroidManifest.xml file missing!
- android 自定义属性步骤