Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试确定我正在运行的设备是否能够发送/接收电话、电子邮件和短信。
我发现我可以使用 TelephonyManager 来获取设备电话号码,而在无法拨打电话的设备上,电话号码为空。这是一个问题。我还没有找到检测电子邮件和短信功能的方法。
如果没有手机信号,SMS 可能是徒劳的,因此您可以使用相同的技巧。
至于电子邮件(=网络),您可能可以遍历您的设备NetworkInterface.getNetworkInterfaces()并查看设备是否已连接。如果您可以连接到互联网,则可以发送电子邮件。
NetworkInterface.getNetworkInterfaces()