通过简单的IntentIntent 设置Action为android.media.action.IMAGE_CAPTURE 然后使用startActivityForResult(intent,REQUEST_CODE)方法进入相机
有时候拍照返回 Uri uri = data.getData();
uri是空的,因为把图片封装到bundle中传递回来
需要需要在bundle中取得图片
Uri uri = data.getData();
if (uri != null) {
photo = BitmapFactory.decodeFile(uri.getPath());
}
if (photo == null) {
Bundle bundle = data.getExtras();
if (bundle != null) {
photo = (Bitmap) bundle.get("data");
} else {
Toast.makeText(DefectManagerActivity.this,
getString(R.string.common_msg_get_photo_failure),
Toast.LENGTH_LONG).show();
return;
}
}