Reputation: 2785
I have 7inch samsung Tab 4. It has cellular network only for internet but doesn't have phone feature. I have created an application to check if there is telephone feature All tabs/Phones work correctly with this condition except the tab that has only data service but not phone service.
How do I check this:
PackageManager pm = this.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY))
{
//PHONE DEVICE
}
else
{
//TAB Device
}
How to fix this issue when there not telephone feature. Let me know!
Thanks!
Upvotes: 0
Views: 372
Reputation: 31
In order to check if a device is a phone, it must be voice capable. The TelephonyManager has a method to explicitly get this value, isVoiceCapable(). This can be determined as follows:
TelephonyManager tm =
(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if(tm.isVoiceCapable()) {
// PHONE
} else {
// TABLET
}
If the TelephonyManager is not voice capable, then it is not a phone, but it may be data capable. More information can be found here.
Upvotes: 0
Reputation: 556
Try below code, it may help you.
if (((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType()
== TelephonyManager.PHONE_TYPE_NONE || ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number()
== null) {
// No Phone
// Do as per your need
} else {
PackageManager pm = this.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
//PHONE DEVICE
} else {
//TAB Device
}
}
This will require the READ_PHONE_STATE permission.
Upvotes: 1