I've noticed on Marshmallow (e.g. Nexus 6P) and also on some more recently updated Lollipop phones (e.g. Galaxy S5) that when I connect to a wifi network that has no internet, the network will not fully connect until the user accepts the prompt stating that the network has no internet access.
Is there any way to programmatically get around this check and allow wifi connections to proceed regardless of internet access?
Restart your device. Open your Settings app and tap Network & internet or Connections. Depending on your device, these options may be different. Turn Wi-Fi off and mobile data on, and check if there's a difference. If not, turn mobile data off and Wi-Fi on and check again.
A common reason why your phone has a WiFi connection but no Internet access is that there is a technical issue with your router. If your router is experiencing any kind of bugs or problems, that affects how your devices including your Android devices connect to the Internet.
Didn't try these but you might try redirecting www.google.com
and 8.8.8.8 to 127.0.0.1 (you can use iptables or modify /system/hosts
). You can also try digging AOSP source code (these are the only isReachable() checks I found in AOSP).
If you decide to lookup AOSP, you can start here
P.S. You'll need root for iptables and /system/hosts manipulation.
You may try this
To verify network availability:
private Boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();
}
To verify internet access(connected wifi is active or not):
public Boolean isOnline() {
try {
Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com");
int returnVal = p1.waitFor();
boolean reachable = (returnVal==0);
return reachable;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With