Android Device phone call ability

前端 未结 7 944
粉色の甜心
粉色の甜心 2020-12-02 23:09

How can I tell whether a given device has the ability to make phone calls?

For example, my Galaxy Tablet cannot initiate call, its not a phone. I want to detect tha

7条回答
  •  忘掉有多难
    2020-12-02 23:15

    I think a better approach would be to query the PackageManager to detect if Telephony features are even available on the device. A device should only have Telephony features if it has a phone. I tested this on a Nexus 7, which does not have a phone, and it works. I do not have a device with a phone to test the opposite case.

    PackageManager pm = getPackageManager();
    
    if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)){
        //has Telephony features.
    }
    

提交回复
热议问题