If you're not distributing your app through the Market and if you don't care about following recommended practices, then you should only need <uses-permission>
tags for any permissions the app uses. However, to allow the correct devices to access the app through the Market, you will need both <uses-permission>
and <uses-feature>
tags.
<uses-permission>
is a request to give your application the authority to take a certain kind of action. When preparing to install your app, the user can review the requested permissions and decide whether to to continue with the installation. If the app, for example, attempts to make a phone call without declaring the "android.permission.CALL_PHONE" permission, then the attempt will fail. See here for a list of base platform permissions.
<uses-permission>
is also used by the Market for implicit feature requirements. If your app uses a permission that needs telephony hardware, then the Market will assume telephony hardware is required, and the app will not be available to a device that lacks telephony hardware.
<uses-feature>
can be used to inform the Market either that a certain feature is required or that the feature is desirable but not required. The tag will override any features implied by <uses-permission>
. If, for example, you specify <uses-feature android:name="android.hardware.telephony" android:required="false" />
, then telephony is not required, regardless of what permissions are requested.
To see how <uses-permission>
and <uses-feature>
interact to create the Market filters, see here.
To check at run time whether a feature is available, it looks like you can use PackageManager.hasSystemFeature():
Context context; // Some object, such as Activity, that extends Context
// ...
boolean hasTelephony = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
if (hasTelephony) {
// ...
}
else {
// ...
}