How does WiFi in android detect if the device has to sign in or not? When the device tries to connect to an access point or router, it has to sign in on the captive portal page with the message saying


  "Sign in to Wi-Fi network".


How does the access point/router identify that a sign in is required for the device and what is the process behind it?
The detection url differs between different Android versions.  

For Marshmallow, it uses connectivitycheck.gstatic.com/generate_204, check the code here AndroidXRef - Marshmallow 6.0.0_r1

For Kitkat, it uses clients3.google.com/generate_204
check the code AndroidXRef - KitKat 4.4.4_r1