You could run a background service on the Android client which pings the webserver at constant time intervals whenever wifi is connected - whenever the client misses a "scheduled" check-in, the webserver concludes that the phone is disconnected, and executes whatever actions you want in that case.
To ping the server, I would use a simple TCP socket:
// you could use IP address instead of the hostname if you don't have a domain name
// PORT_NUM is some value shared between the server and the client e.g. 3456
Socket sock = new Socket("mywebserverurl.com", PORT_NUM);
OutputStream out = sock.getOutputStream();
String data = getDataServerNeeds();
out.write(data.getBytes());
sock.close();
This tutorial has a more detailed example, including the server-side aspect.