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?
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.