How to pick image for crop from camera or gallery in Android 7.0?

后端 未结 9 2269
礼貌的吻别
礼貌的吻别 2020-12-01 04:56

Pick image for crop from gallery and camera it\'s done for below Android 7.0 but in Android Nought it crashes in camera. I use fileprovider for it but doesn\'t work.

9条回答
  •  情歌与酒
    2020-12-01 05:29

        Uri uri = FileProvider.getUriForFile(this, getPackageName() + Configs.FILE_PROVIDER_NAME, inFile);
        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        intent.setDataAndType(uri, "image/*");
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
    

    You should notice that the uri for EXTRA_OUTPUT should not be modified by FileProvider. And your paths.xml should like this

    
    
    
    
    
    

    Because you create crop file under getExternalFilesDir. So is necessary.

提交回复
热议问题