What's the difference between ACCESS_NETWORK_STATE and INTERNET?

前端 未结 3 1829
有刺的猬
有刺的猬 2021-02-03 20:43

What\'s the difference between ACCESS_NETWORK_STATE and INTERNET?

If I use INTERNET, is it necessary to use ACCESS_NETWORK_STATE?

In other words, can I use INTER

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-03 20:57

    From the documentation:

    ACCESS_NETWORK_STATE:

    Allows applications to access information about networks

    INTERNET:

    Allows applications to open network sockets.

    In short, the INTERNET permission lets you use the internet, whereas ACCESS_NETWORK_STATE will just give you information about the network, such as whether you are connected to a network at all.

    You can use either one without needing the other. If you don't check that you have a valid network connection before trying to use the Internet, your HTTP requests will simply fail.

提交回复
热议问题