在项目中可能会遇到在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();
本文介绍如何使用IntentCacheHelper类解决在Intent中传递大数据时遇到的问题,通过实例演示了如何实现数据的高效缓存与管理。

1090

被折叠的 条评论
为什么被折叠?



