New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Nougat 7.0 camera problem #9
Comments
my think 7.0 change file access Passing file:// URIs outside the package domain may leave the receiver with an unaccessible path. Therefore, attempts to pass a file:// URI trigger a FileUriExposedException. The recommended way to share the content of a private file is using the FileProvider. from : https://developer.android.com/about/versions/nougat/android-7.0-changes.html |
This is my changes to fix the issue private void captureImage() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getPackageManager()) != null) {
// fileTemp = ImageUtils.getOutputMediaFile();
ContentValues values = new ContentValues(1);
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
fileUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
// if (fileTemp != null) {
// fileUri = Uri.fromFile(fileTemp);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(intent, REQUEST_CODE_CAPTURE);
// } else {
// Toast.makeText(this, getString(R.string.error_create_image_file), Toast.LENGTH_LONG).show();
// }
} else {
Toast.makeText(this, getString(R.string.error_no_camera), Toast.LENGTH_LONG).show();
}
} |
@andhie Thank you very much for your contribution. Currently I don't have Android N to check your code. As soon as I successfully install Android N on the emulator, I'll let you know. Now I'm fixing other bugs and adding some features. I hope you keep supporting this library to make it more useful! Thanks! |
Any workaround for this issue? |
java.lang.SecurityException: Not allowed to start activity Intent { act=android.intent.action.GET_CONTENT typ=/ } . I got the above exception when I try to launch camera |
Please update to the latest version and let me know if it's works! |
Hi all is that issue resolved now please rply i am in trouble |
@Nonisharma what's wrong with you? |
@andhie |
am trying to display the picture and upload to server, but is crashing using the below code
|
After capture image always getting image rotated and i also try to get orientation code but getting all time orientation 0 .
please suggest me right thing for nougat. Thank you |
When I open camera, it just crash.
android.os.FileUriExposedException: file:///storage/emulated/0/Pictures/Camera/IMG_20160816_135126.jpg exposed beyond app through ClipData.Item.getUri()
The text was updated successfully, but these errors were encountered: