How Can I check if an android device is using a wifi connection or not? I’d like to have an option to auto update my game when connected to wifi.
@MikeNewall,
@265lutab it is old post but may be it will help,
try this,
void Start()
{
string url = “http://google.com”;
WWWForm form = new WWWForm();
WWW www = new WWW(url);
if (www.error == null)
{
//means wifi or mobile data is on
//do whatever you want here like suppose
Application.LoadLevel("login scene");
}
else
{
//means wifi or mobile data is off,
//now do whatever you want to do.
}
}
Here’s what I ended up using
public IEnumerator CheckInternet(){
WWW internet = new WWW("https://image.freepik.com/free-icon/fox-sitting_318-99469.jpg");
yield return internet;
if (internet.error != null) {
isInternet = false;
} else {
isInternet = true;
}
}
I found that I had to use an actual image instead of just http://google.com for the link otherwise it would falsely return true on android.