public static String getCapturePath(Activity activity) {
String path = getImageSavePath() + "/" + getTime("yyyyMMddHHmmss")
+ ".jpg";
Intent cameraintent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraintent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(new File(path)));
activity.startActivityForResult(cameraintent,
Constants.CAMERA_REQUEST_CODE);
return path;
}
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == Constants.CAMERA_REQUEST_CODE)
{
CameraManager.intance().compresImage();
return;
}
}
compresImage();这个方法是压缩图片
public void compresImage()
{
if (!new File(cameraPath).isFile()) {
return;
}
compresPath = AppTools.getImageCompresPath();
// 对图片进行压缩
ImageDispose.compressImage(cameraPath, compresPath, 450);
Bitmap bm = ImageDispose.rotate(BitmapFactory.decodeFile(compresPath));
if(view.getVisibility() == View.GONE){
view.setVisibility(View.VISIBLE);
}
view.setImageBitmap(bm);
view.invalidate();
view.setTag(compresPath);
}
startActivityForResult(); 在重新onResult方法。