1
不工作的相機意圖的活動結果我想從活動結果使用相機獲取圖像。它在android 4.2上正常工作。但我無法從android 2.36獲取圖像。關於在Android 2.36
任何人都可以幫我嗎?源代碼
部分連接如下:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
try {
if (requestCode == 2) {// image from camera
photo = (Bitmap) data.getExtras().get("data");
selectedImageUri = data.getData();
photo = decodeUri(selectedImageUri);
test.setImageBitmap(photo);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
private Bitmap decodeUri(Uri selectedImage) throws FileNotFoundException {
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(
getContentResolver().openInputStream(selectedImage), null, o);
final int REQUIRED_SIZE = 100;
int width_tmp = o.outWidth, height_tmp = o.outHeight;
int scale = 1;
while (true) {
if (width_tmp/2 < REQUIRED_SIZE || height_tmp/2 < REQUIRED_SIZE) {
break;
}
width_tmp /= 2;
height_tmp /= 2;
scale *= 2;
}
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(
getContentResolver().openInputStream(selectedImage), null, o2);
}