it is no problem to check if a valid WiFi connection exists. But how can I ensure only this WiFi connection is used for network access?
Assumed following scenario:
- I check if a valid WiFi-connection exists (and may be I verify if a working Internet connection exists too)
- now this WiFi connection is interrupted
- I start transmitting data over network and now the mobile connection is used because WiFi died recently
How can I avoid that?
Check if WiFi connection exists:
Source, or use this code snippet:
Add a Listener to check if WiFi is still enabled:
Please read Managing Network Usage for a detailed solution