Oh *_*Boy 11 camera android nullpointerexception
照片捕获仅在三星手机上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);
}
}
Run Code Online (Sandbox Code Playgroud)
Ash*_*thi 13
我找到了一个修复(不是我的工作),使其适用于三星设备.有解释的博客可以在这里找到.
但是,在非三星手机上使用此修复程序会返回错误的图像,因此我会使用
if(imageURI != null) {
// do it the normal way
else {
// do it the "Samsung" way
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17366 次 |
| 最近记录: |