有没有人知道通过编程检查Android设备、手机或平板电脑是否具有语音功能的好方法?我所说的语音功能是指打电话的能力。我知道有些设备,比如北美的Galaxy平板电脑,没有这个功能。
发布于 2011-05-25 20:20:18
我自己还没有尝试过,但看起来您需要的详细信息将在TelephonyManager中提供:
private boolean hasPhoneAbility()
{
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if(telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
return false;
return true;
}
发布于 2012-10-17 22:17:38
我知道这个问题很久以前就发布了,但我仍然认为我会发布我想出的解决方案,到目前为止对我来说是有效的,这样任何有同样问题的人都可以受益。(因为似乎很多人都很难找到解决方案)。
我刚刚检查了设备的语音信箱号码,很明显,如果它没有语音信箱号码,那么它就不是电话。在我的代码中,要检查这一点,它是tm.getVoiceMailNumber();
下面是我所做的:
callButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String ableToMakePhoneCalls = tm.getVoiceMailNumber(); //check device for voicemail number (null means no voicemail number).
if(ableToMakePhoneCalls == null){ //If the device does not have voicemail, then it must not be a phone. So it can't call.
//I displayed an alert dialog box here
}
else{
String phoneNum = "tel:8885554444";
Intent intentPhone = new Intent(android.content.Intent.ACTION_CALL);
intentPhone.setData(Uri.parse(phoneNum));
startActivity(intentPhone);
}
}
});
发布于 2011-05-25 20:10:10
从理论上讲,您应该能够使用Intent.resolveActivity
来做到这一点。Galaxy标签页有一个特别的问题(描述为here)。他们显然报告说他们有呼叫能力。您甚至可以成功解析意图。不幸的是,它解析为无操作活动。
https://stackoverflow.com/questions/6130180
复制