Question

My application requires quite a lot permissions.
Lets consider following: Internet, Camera, Fine_location.
The Internet permission is the only one required. For example, I know that only 10% of my customers use Camera and only 2% of my customers use GPS. I also know, that 20% of my customers refused to use my application, after gps features introduction.
As I know, one option if to make separate versions of applications, which has different features.
However, is it possible to give a choice to the user, which permissions he wants to accept? The features, which requires refused permissions, will be disabled. If such features were called an explanation would pop up proposing to accept required permission or to continue without such feature.

Was it helpful?

Solution 2

You can check whether you application have been granted specific permission by using following snippet. ( below I have given example )

if (context
    .checkCallingOrSelfPermission(permission.ACCESS_COARSE_LOCATION) ==
    PackageManager.PERMISSION_GRANTED
    ||
    context
    .checkCallingOrSelfPermission(permission.ACCESS_FINE_LOCATION) ==
    PackageManager.PERMISSION_GRANTED

) {
    // we have been granted above permission.Lets do the task

}

Also for system features you can specify following in manifest.

<uses-feature android:name="android.hardware.telephony" android:required="false" />


PackageManager packageManager = this.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY))

{
    Log.d("TEST", "TELEPHONY IS AVAILABLE");
} else {
    Log.d("TEST", "TELEPHONY IS NOT AVAILABLE");
}

OTHER TIPS

Unless you have ROOT access....

is it possible to give a choice to the user, which permissions he wants to accept?

... the answer is "No", not on stock Android.

If such features were called an explanation would pop up proposing to accept required permission or to continue without such feature.

This would be a security risk - it would make it easier to trick a user into accepting new permissions.

There are some similar questions on this site, and the answers all say the same thing:


Update #1

A previous answer suggested this was possible, but did not provide any code. It has since been deleted, suggesting it can't yet be done.


Update #2

@Neji comments about App Ops that was briefly brought into production (apparently accidentally) before being removed again.

However, this allows permissions to be restricted for certain apps, users. IIRC this did not allow you to grant extra permissions to apps that did not declare them in the manifest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top