问题捕获图像中使用棒棒糖相机 [英] Issue in capture image using camera in lollipop

查看:322
本文介绍了问题捕获图像中使用棒棒糖相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找的以下问题三天

I have been searching for the following issue for three days

我的code是如下

private void openCamera () {    
    try {
        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        String fileName = Constants.IMAGE_CAPTURE_FILE_NAME_PREFIX + System.currentTimeMillis() + Constants.IMAGE_FILE_EXT_JPG;
        mImageFile = new File(FileManager.getInstance().getFileFullName(Constants.IMAGE_FOLDER, fileName));
        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageFile);
        startActivityForResult(captureIntent, Constants.ACTIVITY_CAMERA_REQUEST_CODE);     
    } catch(ActivityNotFoundException anfe) {   
        String errorMessage = "Whoops - your device doesn't support capturing images!";
        Toast toast = Toast.makeText(ImagesSelectorActivity.this, errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}



public String getFileFullName(String folderName, String fileName) {
    String filepath;
    if (PhoneUtils.isSDCardFound() == true)
        filepath = Environment.getExternalStorageDirectory().getPath();
    else
        filepath = Environment.getDataDirectory().getPath();

    File file = new File(filepath, folderName);

    if (!file.exists()) {
        file.mkdirs();
    }

    return (file.getAbsolutePath() + "/" + fileName);
}

在活动结果

if(requestCode == Constants.ACTIVITY_CAMERA_REQUEST_CODE) {

    Uri picUri = data.getData();

    if (picUri == null) {
        Bitmap bitmap = (Bitmap) data.getExtras().get("data");
        Uri tempUri = PhoneUtils.getBitmapUri(getApplicationContext(), bitmap);
        Log.i("AMIRA", tempUri.toString());

    }

    performPreview(picUri);
}

这是图像不救了我的文件夹中返回的问题,而URL是缩略图URI

The problem that the image is not saved in my folder, and the url that return is the thumbnail uri

我需要,我需要,并能够读取图像的完整大小的路径拍摄后的图像保存。

I need to save the image after capture in the path that I need and to be able to read the full size of image.

我找不到在设备的任何地方,从相机拍摄的图像。

I can't find the image captured from camera in any place in the device.

推荐答案

我使用几乎相同的过程,你的工作正常。请尝试以下操作:

I use almost same process as yours that works fine. Please try doing the following:

在开放式摄像机的一部分,而不是发送文件发送乌里是这样的:

In the open camera part, instead of sending File send Uri like this:

mImageUri = Uri.fromFile(mImageFile); //keep mImageUri as member so that you can use it on the activity result.
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);  

在随后的onActivityResult 只是这样做:

if (mImageUri != null && !mImageUri.getPath().isEmpty()) {
    performPreview(mImageUri);
}

希望这有助于!

这篇关于问题捕获图像中使用棒棒糖相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆