I have an android phone that I am using on Page Plus. I am trying to figure out the best way to remotely detect (from a linux webserver) whether or not the device is connected to a wifi network.
I want to disable sms forwarding on my google voice account when not connected to wifi, but since my phone does not have a data connection, this has to be triggered remotely. I know how to program the forwarding setting toggle function, I just need to remotely detect the android device wifi state.
I have thrown around a few ideas, such as monitoring the gtalk status of the phone, and detecting if the android client is online - I can sort of get this to work, but it isn't the cleanest approach in the world.
Any recommendations, or ideas? I know this isn't exactly a programming question, but I would love some help!
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.