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

Cannot open camera if minSdkVersion = 21 #25

Closed
arttor opened this issue Jan 14, 2019 · 3 comments
Closed

Cannot open camera if minSdkVersion = 21 #25

arttor opened this issue Jan 14, 2019 · 3 comments

Comments

@arttor
Copy link

arttor commented Jan 14, 2019

Description

Not able to open camera (nothing happens and no errors in logs)
My project:

compileSdkVersion = 28
minSdkVersion = 21
targetSdkVersion = 28

library version:
implementation 'com.asksira.android:bsimagepicker:1.1.0'
tested on emulator with API lvl 23 25 28
and real device API 28.

During debug i found that

public static boolean isWriteStorageGranted (Context context) {

always returning false. Even after i granted WRITE_EXTERNAL_STORAGE permission.
Unfortunately, this check is mandatory to open camera.

According to official documentation

Beginning with Android 4.4 (API level 19), reading or writing files in your app's private external storage directory—accessed using getExternalFilesDir()—does not require the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions.

This leads to described behaviuor i my project with minSdkVersion = 21:
ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) always returns -1 even after i explicitly granted permission -> camera cannot be opened.

@kroegerama
Copy link

onRequestPermissionsResult handles this just fine on my devices.

@siralam
Copy link
Owner

siralam commented May 7, 2019

@arttor You need to handle run time permissions. If the function returns false it means user haven't granted permission. Your reference to the official documentation is just saying some specific external directories that do not required this permission.

@siralam siralam closed this as completed May 7, 2019
@Morteza-Rastgoo
Copy link

Please update the readme file with this info

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

4 participants