我正在开发一款应用程序,通过设备中可用的相机拍摄照片并将图像返回到Imageview。此代码不适用于设备中的每个相机应用。暂时它只适用于库存相机应用程序[设备 - Karbonn retina A27],如果与其他相机一起使用,应用程序不会返回数据或应用程序挂起
CameraIntent.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==CAMERA_REQUEST) {
if (resultCode==RESULT_OK) {
View view=getLayoutInflater().inflate(R.layout.list_row,null);
ImageView imgView=(ImageView)view.findViewById(R.id.list_image);
Bitmap bitmap=(Bitmap)data.getExtras().get("data");
byte bitObj[]=BirthdayCalculation.convertImageToByte(bitmap);
Log.v("Photo byte.......", bitObj.toString());
ContentValues values=new ContentValues();
values.put(BirthdayProvider.PHOTO, bitObj);
int count=getContentResolver().update(BirthdayProvider.CONTENT_URI, values, BirthdayProvider.NUMBER+"='"+SearchListActivity.longClickValue+"'", null);
if (count==1) {
finish();
imgView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 85, 80, false));
imgView.setScaleType(ScaleType.FIT_XY);
Toast.makeText(getBaseContext(),"Updated Successfully",Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getBaseContext(),"Updation Failed",Toast.LENGTH_SHORT).show();
}
}
}
}