android设备功能检测 [英] android device capability detection
问题描述
我正在尝试确定正在运行的设备是否具有发送/接听电话,电子邮件和SMS的功能。
i'm trying to determine if the device i'm running on has the capability to send/receive phone calls, email, and SMS.
我发现我可以使用TelephonyManager来获取设备的电话号码,并且在无法拨打电话的设备上,该电话号码为空。这是一个问题。我仍然没有找到检测电子邮件和SMS能力的方法。
i found that i can use the TelephonyManager to get the devices phone number and on devices without the capability of making calls the phone number is null. that's one problem down. i still haven't found a way to detect email and SMS capability.
推荐答案
如果没有小区信号,SMS可能就没有用了,所以您可以使用相同的技巧。
SMS is probably futile without a cell signal, so you can use your same trick for that.
对于电子邮件(=网络),您可以在 NetworkInterface.getNetworkInterfaces( )
,然后查看设备是否已连接。如果您可以连接到互联网,则可以发送电子邮件。
As for email (=networking), you can probably iterate through your devices in NetworkInterface.getNetworkInterfaces()
and see if the device is connected. If you can connect to the internet, you can send emails.
这篇关于android设备功能检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!