我正在使用Magical Camera库拍照。在Android 7上可以完美运行,但是当我拍照时(在onActivityResult上调用magicalCamera.resultPhoto(requestCode, resultCode, data);
时,Android 8.0崩溃了)。显示错误Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
。通过单击按钮称为拍照方法:
takePhotoBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isActivePermission(MagicalCamera.CAMERA)) {
magicalCamera.takePhoto();
}
}
});
试图获取照片:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
magicalCamera.resultPhoto(requestCode, resultCode, data);
}
如何解决此问题。检查所有权限(将权限写入清单文件)。