Wi-Fi Disabling Approach

In my Android app, it noticed that when the device goes into standby / standby mode, Wi-Fi is disconnected. When the device wakes up, it reconnects. Before making httpClient.execute (..) on a remote server, we check if the device is connected to n / w. When data transfer is in progress, and if the device goes into sleep mode, and Android runtime will switch to another environment for connection (3G, GPRS, etc.).

  • Is the transition from WiFi to an alternative cellular service let's say 3G seamless?
  • How can I wait for WiFi to become available again? Should I use Thread.sleep (delay) when WiFi wakes up? I saw the broadcast actions when the WiFi status changes.

Overall, what is the ideal approach to turning off Wi-Fi in a mobile application?

+3
source share
1 answer

Why not use WifiManager.WifiLock when the transfer is in progress, and release it when done.

I would suggest that the network connection switch would not be smooth. I do not know for sure.

BroadcastReceiver will notify you when the Wi-Fi connection status changes. Look at the ConnectivityManager, though, because it will control Wi-Fi and GPRS, etc., and it makes a switch to another resource. Is it seamless, although I do not know.

+2
source

Source: https://habr.com/ru/post/1776365/


All Articles