renyuneyun / CamCov

Camera cover / overlay / background app on Android
GNU General Public License v3.0
28 stars 8 forks source link

Prompt for camera permission for Android 6.0+ #3

Closed mo3rfan closed 8 years ago

mo3rfan commented 8 years ago

This is similar to issue #1 and app needs to prompt user for camera permission otherwise it crashes.

renyuneyun commented 8 years ago

right...

Seems that there is no way to tell if the camera permission is denied and also no way to directly open the relavent page/activity.

I'll add a 'welcome' screen which would be shown at first launch.

mo3rfan commented 8 years ago

Are you sure about that?

Because I think you can check for camera permission with this:

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
        Manifest.permission.CAMERA);

If the app has the permission, the method returns PackageManager.PERMISSION_GRANTED

Also, to open relevant page/activity, you don't need to do this yourself, android 6.0 will do it if you call requestPermissions() method with the necessary arguments.

https://developer.android.com/training/permissions/requesting.html

renyuneyun commented 8 years ago

On Android 6.0+, we can use the instructions above and easily grant the desired permission. That's good and certainly need to be implemented.

However, on Android prior to 6.0 (but above 4.4), people can also control the app's permission by using a hidden system Activity (I remember it's called AppOpts). Moreover, there are also some third-party apps (requires root, yes) and custom roms which can control permissions. Under such circumstances, the method above won't work. This is where the idea came out.

mo3rfan commented 8 years ago

Ah I see. But those things you mentioned are unofficial ways to change permission of an app. I think it'll be better to prioritize implementing the way we check and request for permissions for 6.0+ as described in the SDK docs.

renyuneyun commented 8 years ago

v0.4.2 should have fixed this :)

It shall take some time before it goes into the fdroid repo.

If still in trouble, please reopen this issue.

renyuneyun commented 8 years ago

Sorry that I failed to push the tag to GitHub and I wasn't aware of that...

Just created that release (and tag, as I suppose) on the webpage...