amsiddh
amsiddh

Reputation: 3563

Android How to check device/tablet support calling functionality

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.

Upvotes: 6

Views: 4208

Answers (2)

arniotaki
arniotaki

Reputation: 2265

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

Upvotes: 3

Sarim Sidd
Sarim Sidd

Reputation: 2176

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

Upvotes: 10

Related Questions