public static final int TAKE_PHOTO = 1;
public static final int CROP_PHOTO = 1;
String photoPath = Environment.getExternalStorageDirectory().getAbsolutePath()+ photoName + ".jpg";
File file = new File(photoPath);
Uri outPutFileUri = Uri.fromFile(file);
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, outPutFileUri);
startActivityForResult(intent, TAKE_PHOTO);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
// TODO Auto-generated method stub
switch(requestCode)
ccase TAKE_PHOTO:
if (resultCode == RESULT_OK)
{
Intent intent = new Intent("com.android.camera.action.ACTOIN_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, outPutFileUri);
startActivityForResult(intent, CROP_PHOTO);//启动裁剪程序
}
break;
ccase CROP_PHOTO:
if (resultCode == RESULT_OK)
{
try{
Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(outPutFileUri));
imageview.setImageBitmap(bitmap)//显示照片
}catch(Exception e){
e.printStackTrace;
}
}
break;
default:
break;
}