Android Device phone call ability

前端 未结 7 915
粉色の甜心
粉色の甜心 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:20

    You can check only TELEPHONY feature or GSM and CDMA separately:

    private boolean hasTelephony() {
        return getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    }
    

    or

    private boolean hasGsmOrCdma() {
        PackageManager pm = getPackageManager();
    
        boolean gsmSupported = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_GSM);
        boolean cdmaSupported = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);
    //if necessary write somehow what exactly the devise supports
    return gsmSupported || cdmaSupported;
        }
    

    works well!

提交回复
热议问题