(1) You need to define both <uses-permission /> and <uses-feature /> , and then set android:required="false" for this function. For instance,
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-feature android:name="android.hardware.wifi" android:required="false" />
In this case you get permissions, but the function is not required, and you can check if it is available in your code. For this
(2) you should use the PackageManager.hasSystemFeature() method. For instance,
PackageManager mgr = context.getPackageManager(); boolean hasTelephony = mgr.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
source share