80,351
社区成员
发帖
与我相关
我的任务
分享
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch (requestCode){
case TAKE_PHOTO:
if(resultCode==RESULT_OK)
{
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(imageUri, "image/*");
intent.putExtra("scale", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent,CROP_PHOTO);
}
break;
case CROP_PHOTO:
if (resultCode == RESULT_OK)
{
try
{
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
setPhoto(bitmap);
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
}
}
private void setPhoto(Bitmap bitmap)
{
final LayoutInflater layoutInflater = LayoutInflater.from(AverageBillActivity.this);
final View view = layoutInflater.inflate(R.layout.catch_photo, (ViewGroup) findViewById(R.id.wrapper));
ImageView imageView = (ImageView) view.findViewById(R.id.photo);
imageView.setImageBitmap(bitmap);
}