woolnil 2012-02-28
public void onClick(View v) { //启动系统相机 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CASE_CAMERA); }
拍摄完成后的回调函数(在同一个activity中):
protected void onActivityResult(int requestCode, int resultCode, Intent data)方法即可 如: final int TAKE_PICTURE = 1; protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CASE_CAMERA) { if (resultCode == RESULT_OK) { Bitmap bm = (Bitmap) data.getExtras().get("data"); imgPhoto.setImageBitmap(bm); } } }
Feature: 点击选择拍照或者打开相册,选取图片进行裁剪最后设置为圆形头像。Problem: 拍好照片,点击裁剪,弹Toast“无法加载此图片”。Solution: 在裁剪的class里加两行代码