I am trying to get NFC permission at real time, I am able to get any permission except this one, the only way I am able to achieve this permission is by opening the wireless settings of the phone and asking the user to turn it on, is there a way of asking for this permission in runtime from the app without going to the settings?
thanks!
NFC is listed as Protection level: normal in https://developer.android.com/reference/android/Manifest.permission#NFC
And as per https://developer.android.com/guide/topics/permissions/overview#normal_permissions
If an app declares in its manifest that it needs a normal permission, the system automatically grants the app that permission at install time. The system doesn't prompt the user to grant normal permissions, and users cannot revoke these permissions.
From https://source.android.com/devices/tech/config/runtime_perms are only for permissions classed as dangerous
Therefore you don't need runtime permissions to use NFC
But it sounds like you are trying to get permission to turn NFC ON or OFF programmatically which is not really possible
See https://stackoverflow.com/a/11195440/2373819
Related
At least in my two xiaomi's phones when I install my app, it doesn't have all notifications permission (only vibrate, badge and lock screen) like in the pic.
What can I do to in my app to have all the notification permissions enabled by default?
Thanks!
Starting from android 6.0 marshmallow you need to manually give permissions for security reasons. If the application isn't written in such way that it checks for permissions and asks for them, then you can't get them enabled by default(without going to settings).
You need to manually ask for permission for Android 6.0 and above. More informations :
Request App Permissions
I know that since Android 6 apps must request permissions before using an Android feature.
I have two different apps. One of the apps writes to and reads from NFC tags. The other just reads tags. In both cases I have included the permission in the manifest file.
But should I also ask for runtime permissions? Is there a difference between reading and writing or is it the same in both cases?
I ask because when reading the tag the Android system will start my app, so should I ask at startup or is NFC different?
No, there is no need to ask for runtime permissions for NFC. The NFC permission has protection level PROTECTION_NORMAL. Consequently, it is not covered by runtime permissions (i.e. the permission is granted at install time and cannot be revoked/granted by the user at runtime). See https://developer.android.com/guide/topics/permissions/overview.html#normal-dangerous
In Android marshmallow android introduced runtime permissions.
Here my question is Do Android system application such as Camera, Phonebook need to ask for permission like any other non system applications.
Does android system application have some privileges.
Thanks
If you are going to run system applications (by Intent), then you must request the appropriate permissions, except Normal Permissions.
NOTE. And you must remember that the user can at any time revoke the granted permissions.
I am developing an app that does some admin operations on android devices.
The users of android devices running on marshmallow and later has the ability to disable or enable the permissions for a particular app, and I want to restrict the user from disabling my app's permissions since it is an admin app and it need the permissions to run the app.
Is there anyway to restrict enabling/disabling permissions particularly for apps with device administrator privileges?
You Cannot restrict a user from enabling and/or disabling permissions on devices above Marshmallow.
The Only thing you can do is just check if the user has disabled the permission then either explain him why your app needs the permissions and if he is still not giving permissions then don't let him enter the app.
You can check at start of app whether the user has disabled your permission using
ContextCompat.checkSelfPermission(context, permission);
It will return -1 if the permission is not available.
No, This is not under the legal standard of android,
you have to check permission on your app at Splash or First Screen that your app has access that permission or not for move further.
Question
Is it possible to grant Nearby API permissions from phone settings?
If so, how?
Does the answer vary by device API level?
Read on for more context if needed :)
General Background
When an app targeting API level 23 or higher is installed on a device running API level 23 or higher, access to actions that required dangerous permissions can be granted or revoked by the user in two different ways:
while the application is running in the foreground, where calls to requestPermissions result in the user being shown a prompt;
from the Settings -> Apps screen, where users can grant/revoke access to actions requiring dangerous permissions on a app-by-app or group-by-group basis.
In particular, a user who has denied a permission that has been requested (at least) twice via mechanism #1, and who has checked 'Never ask again' in the most recently-displayed prompt:
can still choose to grant that permission at a later time using mechanism #2.
Nearby API Background
When an app wishes to use the Nearby Messages API, a mechanism similar to (but distinct from) #1 can be used to request the necessary permissions at runtime. As far as I can tell, these permissions are not represented within any of the standard dangerous permissions groups.
Just like for typical dangerous permissions, it is possible for a user to instruct an application to 'Never ask again' for the Nearby API permission (example from Pocket Casts; device running API 23):
However, if a user selects this option it would appear to be totally permanent. Here are the listed permissions groups for Pocket Casts immediately after denying access to the Nearby APIs with 'Never ask again' checked:
The only dangerous permissions group present is Storage, and access is still granted. There's no sign of the Nearby API permissions, and I therefore don't see how it is possible to ever grant access to these permissions after reaching this state... (apart from uninstalling and reinstalling the application, which isn't ideal!)
Edit
In more recent testing I seem unable to permanently deny the Nearby permission. Even after the first denial, the "Never ask again" checkbox does not appear. I am guessing this was introduced by a change in the Google Play Services version running on my phone. Here's what the permissions dialog looks like now. Note that it includes specific instructions related to locating the Nearby permission setting!
As pointed out by Morrison Chang in the comments, Nearby API permissions control is located under Settings -> Google. Here's an animated gif showing how to grant access to the Nearby APIs on an app-by-app basis, starting from the settings screen of a Nexus 6 running Marshmallow:
As a developer, this makes sense to me in hindsight - it's the only way Nearby permissions management could be backported to pre-Marshmallow devices. As a user, though, I definitely found this confusing!