照片捕获 Intent
仅在三星手机上导致 NullPointerException
。
下面的实现。
final Button capture = (Button)findViewById(R.id.capture_button);
capture.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
ImageView image = (ImageView)findViewById(R.id.photoResultView);
image.setImageBitmap(thumbnail);
}
}
最佳答案
我找到了适用于三星设备的修复程序(不是我的工作)。有解释的博客可见here .
但是,在非三星手机上使用此修复会返回错误的图像,因此我会使用
if(imageURI != null) {
// do it the normal way
else {
// do it the "Samsung" way
}
关于android - 照片捕获 Intent 仅在三星手机上导致 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7031374/