In my app there is a calling functionality. On click of "Call" button, app will launch the phone dialer with phone number.
Now if any of the device/tablet is not having the calling functionality, in that case i want to check this
if(isSupportCalling)
//launch dialer
else
//show message
inorder to avoid any application crash.
As this permission will only allow android play to make it visible and able to download/install the app on device/tablet which don't support calling functionality.
<uses-feature
android:name="android.hardware.telephony"
android:required="false"/>
As i had seen very few threads on SO related to this, but didn't find a reliable way to this.
By using TelephonyManager class, you can tell the availability of phone network as well as you can check for different related state of phone network.
TelephonyManager tm= (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
if(tm.getPhoneType()==TelephonyManager.PHONE_TYPE_NONE){
//No calling functionality
}
else
{
//calling functionality
}
Hope This Helps
That's it:
You should do the following:
private boolean canMakeCalls(){
return ((TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number()
!= null;
}
and just call the function whenever you want:
if (canMakeCalls()){}
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With