Android: send data only via WIFI


I have a service that runs in background and send data to a server, I want to send this data only by wifi and not another way (gprs or else) is that possible? and if it is, how can I achieve that? if you have sample codes or links that would be great. thank you.

final ConnectivityManager connMgr = (ConnectivityManager)

final wifi =

The NetworkInfo structure should have the connectivity state of the Wifi Subsystem. Look at the documentation:

Use the isConnected method to see if wifi is connected. Easy Peasy!