Support for Android devices with and without phone capabilities

I have an application that will run on devices with phone capabilities, but it’s not. Here are some of my queries:

1) Can I support both types of devices. 2) For devices with phone capabilities, I need to enable the call function. and a device that does not have the ability to use a phone will disable the call features.

I don’t quite understand what the <user-permissions> and <user-features> concept is, there is a way to specify the phone functions <user>

+2
source share
2 answers

If you do not distribute your application through the Market, and if you do not need the following recommendations, you only need the <uses-permission> tags for any permissions that the application uses. However, to allow the correct devices to access the application through the Market, you will need the <uses-permission> and <uses-feature> tags.

<uses-permission> is a request to grant your application the authority to take certain actions. In preparation for installing the application, the user can view the requested permissions and decide whether to proceed with the installation. If the application, for example, tries to make a phone call without declaring the permission "android.permission.CALL_PHONE", the attempt will fail. See here for a list of permissions of the underlying platform.

<uses-permission> also used by the market for implicit performance requirements. If your application uses a resolution that requires telephony hardware, the market suggests that telephony hardware is required and the application will not be available for a device that does not have telephony hardware.

<uses-feature> can be used to inform the Market that a specific function is required or that this function is desirable but not required. The tag will override any functions that are 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 market filters, see here .

To check if a function is available at run time, 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 { // ... } 
+13
source

Well, I don’t know about a really simple way to do this, but you can use the method below to get the phone number of the phone, and if it returns null, it probably means that the phone’s functions are not available and it’s a tablet or something. rode (a microwave with Android ?: p)

 private String getMyPhoneNumber() { TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); return mTelephonyMgr.getLine1Number(); } 

Also, be sure to add the permission "android.permission.READ_PHONE_STATE" to the Android manifest file. Good luck :)

0
source

All Articles