Open VDshixiaoming opened 7 years ago
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference at com.lling.photopicker.utils.ImageLoader.cacheBitmap2Disk(ImageLoader.java:317)
你这种问题。。完全没法回答,照片权限不都是自己写吗。。
May I have a question? how to use the picker in the dialog?
在执行内存缓存的线程里,把空值异常捕捉一下,可能是解析的图片出现问题 class DiskCacheThread extends Thread {
String path;
Bitmap bitmap;
public DiskCacheThread(String path, Bitmap bitmap) {
this.path = path;
this.bitmap = bitmap;
}
@Override
public void run() {
try {
String key = OtherUtils.hashKeyForDisk(path);
DiskLruCache.Editor editor = mDiskLruCache.edit(key);
if (editor != null) {
OutputStream outputStream = editor.newOutputStream(0);
if (cacheBitmap2Disk(bitmap, outputStream)) {
editor.commit();
} else {
editor.abort();
}
}
mDiskLruCache.flush();
} catch (IOException e) {
e.printStackTrace();
}catch (NullPointerException e){
e.printStackTrace();
}
}
}
启动就蹦,手动开了摄像和存储访问权限后才能运行。选择图片时往下滑就会报错,在PhotoPickerActivity的OnDestroy加
后面滑动还是会报空指针错误