Using ConnectivityManager
, I can check if the user is connected to WiFi. If yes, my app begins downloading. After writing the data to local storage, I check again if the user is connected to WiFi. If not, I stop the downloading.
Now, what I want to know is.. how do I ensure that the HttpURLConnection
made is via WiFi ?
Another feature is where the user is liberal about the downloads. user allows the app to download either via WiFi or via network.
Assume a scenario where the user has WiFi turned on. The app checks if WiFi is available and begins downloading. Later, user switches off WiFi or moves out of the signal range. What happens to the connection then? Does it switch over to using network?
Also, how do I ensure that the HttpURLConnection
is made via network?
All in all, I just need to avoid a nasty situation where the user ends up spending a lot of money accidentally over download. This is not a very critical app, I am doing this just for practice