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!
Related
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
I want to make an app that essentially mines every bit of data that it can from a phone for a university research project. For this, I will need to know what apps are open (all of them) and it seems that, as of API 21, just listing the current app is a rather tricky endeavor. If the user grants superuser access requested via:
<uses-permission android:name="android.permission.ACCESS_SUPERUSER">
</permission>
can I get around Googles obvious attempts to make it harder to get even tiny bits of information out of the phone. Or have they gone as far as making superuser access not so super anymore?
Also, I know I can just root the device, but this application will be installed on other peoples devices (data will be stored locally). As I understand it, non rooted devices can still grant superuser access upon permission (or via toast message if permissions are not listed in the manifest)
EDIT: apparently, as of android 5.0, SU is no longer available to non rooted devices...
Thanks
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.
I want to enable/disable location services for my app but not have to prompt the user to enable it if it's turned off. All the examples I have seen require some dialog to be shown. This seems kind of senseless given that the user has already granted permission to use location services.
I want to enable/disable location services for my app but not have to prompt the user to enable it if it's turned off.
Fortunately, that is not possible on ordinary devices, for obvious privacy reasons, barring some bug in Android (or specific device models). System apps might be able to do this, and this should be possible on rooted devices, though I do not have the details for either scenario.
This seems kind of senseless given that the user has already granted permission to use location services.
Prior to Android 6.0, users did not have the ability on ordinary Android devices to control permissions individually. As a result, they might disable location services, just to be able to use apps that happen to request locations.
Even on Android 6.0+, just because the user granted your app permission to use locations does not mean that the user wants location data to be available all the time. They might only want locations to be available to apps at certain times (e.g., while travelling and needing location-related information more). Or, as a commenter noted, the user might keep locations disabled for power reasons, more so than privacy.
if the app needs control of the location service and the user is made fully aware that the app needs to turn it on/off when it is running
That would need to be a separate capability with a separate permission (e.g., some MANAGE_LOCATION_PROVIDERS permission), or possibly be part of the device admin/device owner APIs. You are certainly welcome to file a feature request for this.
No prompt should be necessary if the permission has been granted
Permissions to access location data do not imply permission to override the user's enabled/disabled setting for location providers. If it did, there would be no point in having location providers be able to be disabled.