Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optional permissions so an app can show on all devices and enable optional features on some?

Many features in Android require a uses-permission to be set in the manifest. These values then determine what devices will see them in the Market. However, what should be done if the feature is optional... if it could be made to run on many devices, but would require the permission only on a few?

An example: let's say an app with multiple features and a good amount of content--and it provides a button to call the company. That's a nice convenient feature, as opposed to writing down the number or copying and pasting it into the phone app. It's not essential, however.

If that feature is used and the telephony permission is added to the app, then that's all well and good for phones--but no tablet would see the app in the Market.

What is a general solution for this problem?

Multiple apps could be made with different permissions, but there's a world of problems with that approach (extra development time, difficulty of keeping maintenance consistent, reviews and ratings split across different apps, and if there are several different types of optional permissions than a different app may be needed for each combination).

The app could programmatically check if the feature is available and enable it or disable it depending on the device. The problem with that is that if the app doesn't have the permission, then it will crash if it tries to use that feature--and if it does have the permission, some devices won't be able to find the app in the Market.

In certain cases, it may be possible to cut out nonessential features from the app entirely to avoid the issue. That's not a great solution either, since those features WOULD be "nice to have" on devices that support it.

Yes, I am aware Is it possible to have "optional" permissions in Android? is a similar question. I'm hoping for newer information and for other workarounds people have found, if any... what is the solution to this issue? Does anyone have other approaches besides the ones I've listed above?

like image 419
Chad Schultz Avatar asked Feb 15 '12 19:02

Chad Schultz


People also ask

How do I allow permission to access all apps?

Here's how to access the app permissions list to see all apps that use a specific permission: Open Settings and tap Apps & notifications. Tap Permission manager to open the Android permission controller app. Click a specific permission from the app permissions list that you're interested in, like location.

Can I turn off all app permissions?

To see a more comprehensive list of permissions, you can tap on the Apps & notifications screen, then tap App permissions. In this window, you can browse apps by the permissions they access, and turn off any you like.

How do I grant all permissions to Android apps?

You can grant all run-time permissions on installation by using; adb install -g. Or just use ';' between each pm grants like this?


1 Answers

What is a general solution for this problem?

For that specific problem, add <uses-feature android:name="android.hardware.telephony" android:required="false"/> to your manifest, to indicate that this feature is optional. You can then use PackageManager and hasSystemFeature() to determine if a device has the non-required feature at runtime.

like image 168
CommonsWare Avatar answered Sep 21 '22 00:09

CommonsWare