Broadcast Intent when network state has changend

前端 未结 3 1927
轮回少年
轮回少年 2020-12-01 02:03

Does Android broadcast an intent when the network state has changend, i.e. from GSM to Wifi? And if so what permission do I need and what is the intent action called?

相关标签:
3条回答
  • 2020-12-01 03:02

    Update: please use this instead: https://stackoverflow.com/a/2677519/241869

    0 讨论(0)
  • 2020-12-01 03:05

    There isn't anything exactly like what you are describing but you can use ConnectivityManager.CONNECTIVITY_ACTION to monitor changes and use the extras that come with it to see if the connection has changed from GSM to Wifi and vice versa. For this you need the permission android.permission.ACCESS_NETWORK_STATE and android.permission.ACCESS_WIFI_STATE for checking wifi information.

    0 讨论(0)
  • 2020-12-01 03:08

    Android will broadcast WifiManager.NETWORK_STATE_CHANGED_ACTION when the devices gains or looses wifi connectivity. You'll need the permission android.permission.ACCESS_WIFI_STATE to receive the intent. However, I'm not sure if there's something similar for GSM -> WIFI.

    0 讨论(0)
提交回复
热议问题