2

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.

Yarh
  • 4,459
  • 5
  • 45
  • 95
  • 2
    Google had AppOps but they removed it in the lastest update of 4.4.2 but seriously i feel there must be a window where user can update the permissions asked by apps but that might increase work of developers as before using any API they will have to check if permission was granted or no – Neji May 07 '14 at 06:53
  • @Neji true, added comment on that to my answer. Thx for pointing it out – Richard Le Mesurier May 07 '14 at 06:55

2 Answers2

3

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.

Community
  • 1
  • 1
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255
  • @Yarh Which Trulia app? [Real Estate & Homes by Trulia](https://play.google.com/store/apps/details?id=com.trulia.android) requests `Your location` right at the top of the permission list. In researching this answer for you, I read somewhere that the Play Store app had a permission bug in it at some point (can't find the link again tho) – Richard Le Mesurier May 07 '14 at 07:08
  • Yes, it is there now. Ill delete previous comment, as I cannot provide support – Yarh May 07 '14 at 07:14
  • @Yarh - that's a pity - I was hoping to find some exception to the rule – Richard Le Mesurier May 07 '14 at 07:20
0

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");
}
Vipul
  • 27,808
  • 7
  • 60
  • 75
  • 2
    It looks nice. However, when user install application from google store, he is asked to accept `all` permissions which are listed in manifest. He just don't have a cohice not to accept some of them or it is possible to give a user such choice? – Yarh May 07 '14 at 06:16
  • 1
    @vipul which latest versions are you talking about ? android does not give any privilege to disable any permission asked by application!! – Neji May 07 '14 at 06:45
  • 1
    @VipulShah from http://developer.android.com/guide/topics/manifest/uses-feature-element.html as I understand still asks for permissions. It was given to allow install application on devices, which misses some hadware and that missed hardware is not crucial for application – Yarh May 07 '14 at 07:24
  • @Yarh @Vipul Maybe the downvote is because this doesn't answer the question: `is it possible to give a choice to the user, which permissions he wants to accept?`. – Richard Le Mesurier May 07 '14 at 07:26
  • "However, is it possible to give a choice to the user, which permissions he wants to accept?" - sure, the app can ask the user if they want to allow something, but then they have to trust the app to honor that choice. Stock Android does not provide a line-item veto for permissions, but I believe some of the alternative builds do. It would be interesting if the code provided here interacts well with those or not. – Chris Stratton May 07 '14 at 15:41