- Home /
Check if Android device using wifi?
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.
Answer by ankitdave · Jun 02, 2016 at 04:57 PM
@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.
}
}
Answer by 265lutab · Jun 03, 2016 at 06:05 PM
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.
Your answer
Follow this Question
Related Questions
Game broken after Unity 4.5.1 update 1 Answer
Unity android ads 0 Answers
Button not update()ing,Button not updating 1 Answer
Input.touchCount works in one script but not the other 1 Answer