Android设备的电话功能 [英] Android Device phone call ability

查看:94
本文介绍了Android设备的电话功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何知道一个给定的设备是否有拨打电话的能力?

例如,我的Galaxy平板电脑不能,它不是一个电话。我想检测,这样做调用isIntentAvailable(背景下,Intent.ACTION_DIAL)我已经试过检查isIntentAvailable此之前,但这似乎不是要走的路。

解决方案

 如果(((TelephonyManager)的getContext()。getSystemService(Context.TELEPHONY_SERVICE))。getPhoneType()
    == TelephonyManager.PHONE_TYPE_NONE)
{
    //没有电话
}
 

修改我很惊讶,它回来了 PHONE_TYPE_CDMA 。这里的另一种可能性:

 如果(((TelephonyManager)的getContext()。getSystemService(Context.TELEPHONY_SERVICE))。getLine1Number()
    == NULL)
{
    //没有电话
}
 

这将需要 READ_PHONE_STATE 许可。

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

For example, my Galaxy Tablet cannot, its not a phone. I want to detect that before doing a call to isIntentAvailable(context, Intent.ACTION_DIAL) I've tried checking the isIntentAvailable for this, but that doesn't seem to be the way to go.

解决方案

if (((TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType()
    == TelephonyManager.PHONE_TYPE_NONE)
{
    // no phone
}

EDIT I'm surprised it comes back PHONE_TYPE_CDMA. Here's another possibility:

if (((TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number()
    == null)
{
    // no phone
}

This will require the READ_PHONE_STATE permission.

这篇关于Android设备的电话功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆