//首先呢 先把依赖导入进去
public class MyAppliction extends Application {
@Overridepublic void onCreate() {
super.onCreate();
//是一个工具类,在下面
//ImageLoader初始化设置
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
.memoryCacheExtraOptions(320, 320) // default = device screen dimensions 内存缓存文件的最大长宽
.diskCacheExtraOptions(320, 320, null) // 本地缓存的详细信息(缓存的最大长宽),最好不要设置这个
.threadPriority(5) // default 设置当前线程的优先级
.tasksProcessingOrder(QueueProcessingType.FIFO) // default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024)) //可以通过自己的内存缓存实现
.memoryCacheSize(2 * 1024 * 1024) // 内存缓存的最大值
.memoryCacheSizePercentage(13) // default
.diskCacheSize(50 * 1024 * 1024) // 50 Mb sd卡(本地)缓存的最大值
.diskCacheFileCount(100) // 可以缓存的文件数量
// default为使用HASHCODE对UIL进行加密命名, 还可以用MD5(new Md5FileNameGenerator())加密
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
.writeDebugLogs() // 打印debug log
.build(); //开始构建
ImageLoader.getInstance().init(configuration);
}
}
public class MyExceptionHandler implements Thread.UncaughtExceptionHandler {
private static MyExceptionHandler myexceptionhandler = null;
private MyExceptionHandler() {
}
public static MyExceptionHandler getInstence(){
if(myexceptionhandler == null){
synchronized (MyExceptionHandler.class){
if(myexceptionhandler == null){
myexceptionhandler = new MyExceptionHandler();
}
}
}
return myexceptionhandler;
}
public void setDefaultUnCachExceptionHandler(){
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
Log.d("Exception",throwable.getMessage());//打印异常信息
/**
* 可以对异常信息作出上传服务器的操作
*/
}
}