Skip to content
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

camera click image not coming in result on android 11 #822

Open
geeta4 opened this issue Mar 12, 2021 · 6 comments
Open

camera click image not coming in result on android 11 #822

geeta4 opened this issue Mar 12, 2021 · 6 comments

Comments

@geeta4
Copy link

geeta4 commented Mar 12, 2021

error in result while picking camera image on android 11

Failed to load sampled bitmap: file:///storage/emulated/0/Android/data/com.hhstudio/cache/pickImageResult.jpeg
File is not a picture

@Canato
Copy link

Canato commented Mar 15, 2021

@geeta4 please check:

#818

@sachin-varshney
Copy link

Replace the method getCaptureImageOutputUri in the CropImage.java file with the below code, might solve the problem.
it worked for me

public static Uri getCaptureImageOutputUri(@nonnull Context context) {
Uri outputFileUri = null;
File getImage = context.getExternalCacheDir();
if (getImage != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider",
new File(getImage.getPath(), "pickImageResult.jpeg"));
} else {
outputFileUri = Uri.fromFile(new File(getImage.getPath(), "pickImageResult.jpeg"));
}
}
return outputFileUri;
}

@Softkeydel
Copy link

Softkeydel commented May 3, 2021

How to get the actual file path from the FileProvider.getUriForFile()
How do I get path like file:///storage/emulated/0/Android/data/com.hhstudio/cache/pickImageResult.jpeg

Please help me if there is any solution.

@Canato
Copy link

Canato commented May 4, 2021

How to get the actual file path from the FileProvider.getUriForFile()
How do I get path like file:///storage/emulated/0/Android/data/com.hhstudio/cache/pickImageResult.jpeg

Please help me if there is any solution.

@Softkeydel please read #818

The new version has a method for it

@ahmednabeel1991
Copy link

Replace the method getCaptureImageOutputUri in the CropImage.java file with the below code, might solve the problem.
it worked for me

public static Uri getCaptureImageOutputUri(@nonnull Context context) {
Uri outputFileUri = null;
File getImage = context.getExternalCacheDir();
if (getImage != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider",
new File(getImage.getPath(), "pickImageResult.jpeg"));
} else {
outputFileUri = Uri.fromFile(new File(getImage.getPath(), "pickImageResult.jpeg"));
}
}
return outputFileUri;
}

thank you very much. This works for me also

@IMWaqasFarooq
Copy link

how to change that file, because its read only file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants