android 调用系统相机拍照获取照片时,为什么先跳到桌面,然后再回到调用相机的Activity 20
展开全部
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);
}
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);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询