我应该使用 ConnectivityManager 和 WifiManager 而不是 Read_Phone_State 吗?
好吧,Stackoverflow 上到处都有人说,要检查网络连接是否可用,我应该将权限 READ_PHONE_STATE
添加到清单中 - 这对我来说非常难看(尽管市场上的许多应用程序都具有该权限)许可,我认为这有点过分了;你可以获取 IMEI、用户电话号码等)。
因此,我偶然发现了权限 ACCESS_NETWORK_STATE
和 ACCESS_WIFI_STATE
,它们应该给出相同的结果。没有人使用它们有什么原因吗?
因为如果没有,我就不需要 READ_PHONE_STATE 权限,这样就不那么可怕了(或者用户实际上并不关心?)
谢谢!
Okay, so everywhere on Stackoverflow people say, to check if a network connectivity is available I shall add the Permision READ_PHONE_STATE
to the manifest - which is pretty ugly to me (even though many apps in the market have that permission, this one is an overkill I think; you get the IMEI, the users phonenumber etc).
So I stumbled upon the permissions ACCESS_NETWORK_STATE
and ACCESS_WIFI_STATE
, which should give the same result. Is there a reason why nobody uses them?
Because if not, I would not need the READ_PHONE_STATE
permission, which is a little bit less scary (or do users actually don't care anyways?)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在许多应用程序中使用了这些权限。
BroadcastReceiver
可以检查网络何时更改状态,或者您可以使用类似这样的内容检查连接状态 (来源):I have used these permissions in many of my applications. A
BroadcastReceiver
can check when the network has changed states, or you can check the connection status with something like this (source):