Must I declare all the permissions in the Manifest as before?
I'm asking it for a reason - let's have a scenario that you introduce a new feature to your app that requires the Contacts permission, and let's think about it from a product perspective.
When it comes to Marshmallow users, everything will be okay (concerning UX) - upon update, they won't ask for new permissions, but only the moment of need. That's fine with me.
But, prior Marshmallow users will be requested for the new permission upon update, and may disapprove it, and by that, won't update the app. Not good.
What if I want my new feature to be available only for Marshmallow users and above, while older versions users won't get the feature and be asked for the new permission upon update? Can I do something like this?
Hope I was clear enough.
Must I declare all the permissions in the Manifest as before?
They must be in the manifest, yes.
What if I want my new feature to be available only for Marshmallow users and above, while older versions users won't get the feature and be asked for the new permission upon update? Can I do something like this?
Yes. Use the awkwardly-named <uses-permission-sdk-23> element as a replacement for <uses-permission>. On API Level 22 and older devices, this element will be ignored. On API Level 23+ devices, you can request the permission at runtime as normal.
Related
In our app we just added the following permission : android.permission.QUERY_ALL_PACKAGES
on top of other pre-exisitng permissions.
This permission is a sensitive permission so we did everything that needed to be done in the Play Console.
Anyways, now we can publish the app in the Play Store so that is sorted.
Unfortunately we experience strange behavior, specifically during a clean install of this new app version everything works as expected. So functionality depending from this permission is working just fine.
But if this permission is introduced whilst executing an update of the app the functionality which depends from this permission is not working appropriately. It actually behaves like the permission has not been granted. When I do look in the Settings->App info screen regarding all the app permissions I do so see the query all packages permission...
We are at a loss here.
Does a newly introduced permission work right away after an app update ?
This is not a permission that needs to be requested (or granted) during runtime, or at least that is what we think.
Does anyone have experience regarding this different behaviour during an app install or an app update ?
I have an app which contains <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Is there a way to delay asking the user for the location permission until they take an account which requires it? I've tried removing uses-permission from the XML, this breaks location even after programmatically asking for location permissions.
I do programmatically ask for location info, but that only seems to work if the permission is also specified in the XML.
I am assuming that you are experiencing this as you're targeting below Android 6.0?
As per the docs
Android 6.0 Marshmallow introduced a new permissions model that lets
apps request permissions from the user at runtime, rather than prior
to installation. Apps that support the new model request permissions
when the app actually requires the services or data protected by the
services.
Therefore, you will be unable to avoid requesting permissions before the user actually needs to use that particular service, unless you target a higher API level.
If you need permission, you can not remove it from manifest. If your target API is above 23 (Android 6) Just ask for permission programmatically when you need it. You as developer determine when to ask for permissions.
Otherwise if user's device is below android 6 or if your target API is below 23 then permissions will be requested at install time and you can not change it.
Is there a way to automatically accept permissions on a user's mobile and without the interaction of the user with the app? When the app launches, the permissions should be accepted automatically. Please suggest me any idea/hack to do it.
Thanks
Yea its possible , For that you need change targetSdkVersion (SDK v26 or any version above to SDK v22) to targetSdkVersion SDK v22 in build.gradle , in this case it will not ask to user to grant perssion , it will take permission automatically and why its working because granting permission introduce in sdk 23 and above
Note :- it may be ask permission in OPPO phones , Vivo etc while runtime.
Sample Peoject Link :- https://github.com/kdblue/PermissionGranted
No problem if the solution is illegal but I want a way to do it
Whats this mean?
First of all this is impossible. If you are working on a technology then you have to follow its guidelines.
The second thing is if your app targets Android M or greater then you have to follow the Permission model .
If your app target is below Android M then you do not have to ask for Runtime permission, the permissions will automatically granted on installation all at once.
Note:- Starting from Android M User can manually allow/disallow the permission to any third party app . So in that case you won't get SecurityException but your feature would not work .
Conclusion:- As you see your app is going to effect anyhow whether its targets low or high, So its better to follow the Permission model and make use of Android's new version's. As Android's new versions rolls out to more and more users, apps that request permissions at the time of installation will be viewed as un-maintained or poorly written, as users will expect not to have to agree to permissions up front, which leads to bad user experience .
I am aware about the changes introduced in Android 6.0/SDKVersion 23 regarding the app permission. There is excellent discussion on this topic in the below post.
"Android permission doesn't work even if I have declared it"
Now post Android 6.0, we require to verify and seek various permission during run-time as discussed here.
With this, Does adding tag in AndroidManifest.xml will have any meaning/use case post Android 6.0 targeted devices only?. Or we can remove these entry.
You always need to list your permissions in the manifest. Quoting the developer page covering Requesting Permissions at Run Time:
On all versions of Android, your app needs to declare both the normal and the dangerous permissions it needs in its app manifest, as described in Declaring Permissions.
If you don't, you'll probably end up with an Exception at runtime when trying to check or request them.
I am dealing with runtime permission requesting for my app so that I can upgrade to API 23. From trial and error, it appears that the GET_ACCOUNT and MANAGE_ACCOUNT are no longer required for SyncAdapter with stub ContentProvider and Authenticator?
I even removed the permissions from manifest and nothing seems broken. Is this a new change? I remember ~1 year ago I tried finding a way to not have to include those permissions (since I was only using a stub authenticator) and it wasn't possible.
Is there any explanation for this? Just want to make sure those permissions are really no longer needed and that I am not breaking some underlying thing by removing them.
Yes. Some things changed, but you should probably still keep them included in your manifest (especially if you are also targeting devices with android < 23).
You do not specify which methods you use that required this permission, but you can e.g. see it with AccountManager.getAccountsByType(String) where it says:
NOTE: If targeting your app to work on API level 22 and before, GET_ACCOUNTS permission is needed for those platforms, irrespective of uid or signature match. See docs for this function in API level 22.
So yes, some methods changed, but to remain on the safe side (and be compatible with older android versions) you should still include those permissions.