In Android emulator 2.1, my code works to capture an image , but it doesn't work in other versions of android
,
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAMERA_RESULT);
,
if (resultCode == RESULT_OK && requestCode == CAMERA_RESULT) {
Bundle extras = data.getExtras();
if(extras.containsKey("data")) {
Bitmap bmp = (Bitmap) extras.get("data");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] image = baos.toByteArray();
if(image != null) {
}
}else {
Toast.makeText(getBaseContext(), "Fail to capture Image", Toast.LENGTH_LONG).show();
}
}
Edit:
.