Android GPS Permission in Marshmallow - android

As we know in Marshmallow we need to ask permission from users.
Recently I have installed BookMyShow and found there is no dialog pop up for permission.
When I checked from setting->app, All required permissions were there.
how do they do it? ..

Their targetSdkVersion is lower than 23, presumably.

Related

below 23 android xiaomi devices permission

So I have camera permission in manifest , Still when app goes to start camera it crashes .this happens beacuse user had denied the permission in permission manager for camera that comes with xiaomi devices
So the app Crashes , can someone help about how to handle this.
with the normal way of getting permisions , it does not give correct result
String permission = "android.permission.CAMERA";
int res = getContext().checkCallingOrSelfPermission(permission);
res is always 0(has Permission) for below 23 devices , if user has manually denied permission by going to permission manager then also
Revoking permissions on android devices below 23 is non-standard behavior and is afaik only possible through customized OS versions (like Cyanogen mod or in your case, the Xiaomi modified version). Users should be aware, that revoking permissions that way may cause error ins apps.
Prior to Android 6.0, you could reasonably assume that if your app is running at all, it has all the permissions it declares in the app manifest.
https://developer.android.com/training/permissions/best-practices.html#testing
Therefore I suggest you run your methods that require a certain permission with a try/catch. If the api lvl is below 23 and your method call fails, you know for sure if you have the permission or not.

How to ask for Runtime App Permissions on Pre Marshmallow Custom Android OS like Xiaomi, Lava, Cyanogen Mod?

I have faced problems while getting Location data in OEM's Custom OS (Pre-Marshmallow i.e. Android Version < 6.0) with Permission Managers where the user can deny Location permission to the app.
Is there a way to detect that the permissions have been denied and also a way to ask for those permissions?

How Android Lollipop and other devices ask location permission?

After further research, i found that requestPermission only works on Android M. If i just include the permissions i needed in android manifest file, how does android ask user for the permission granted? For example, access fine location permission. I try including the requestPermission but never see the dialog.
Before Marshmallow, all the permissions are granted at installation time. That's why you don't see a dialog requesting permission on Lollipop and previous versions on runtime.
Check this out: Runtime Permissions. It only applies to Marshmallow and above.

detect if permissions revoked or not

I'm using a rooted M device and trying to access the permissions setting for other apps.
I would like to know which permissions are granted or revoked by user for each app
can this be available?
can checkSelfPermission() work for that?
Also, if I'm downloading an app which is not developed for M version can the detection operation work or not because I found that any app whit target version lower than 23 will always return PERMISSION_GRANTED
checkSelfPermission returning PERMISSION_GRANTED for revoked permission with targetSdkVersion <= 22

Android's ContextCompat.checkSelfPermission() returns incorrect value

I am trying to check for permissions being granted/revoked by user in Android Marshmallow. Unfortunately ContextCompat.checkSelfPermission() (which is a warpper around Context.checkCallingOrSelfPermission) seems to always return PackageManager.PERMISSION_GRANTED (0) if you have included that specific permission in your manifest regardless of the current state of the permission (e.g. if the user has revoked the permission). I also tried someContext.checkCallingOrSelfPermission(), but the result is the same.
Has anyone experienced this? I am using Android Marshmallow on nVidia Shield console (using nVidia's Beta program).
As it turns out, The targetSdkVersion in the manifest must be 23, mine was 22. If your target SDK is 23 (Android 6), all of the permissions (in your manifest) are disabled by default, whereas if your target SDK is 22 (Android 5.1) and your app is running on Android 6, all of the permissions are enabled by default when the user installs the app, and even if the user revokes the permissions later on, the mentioned API returns incorrect value (which is a bug in my opinion).

Categories

Resources