When Wifi disconnect, how does Socket on Android server side know that? -
i developed android app, works in wifi ap mode socket server. clients setup wifi connection , socket connection app. when socket connected, disconnect wifi connection client, there no exception nor read method of socket return -1 in server app. questions are:
- how detect broken wifi connection
- how detect client's wifi connection broken
thanks.
use in thread
public static boolean checknetworkconnection(context context) { final connectivitymanager connmgr = (connectivitymanager)context.getsystemservice(context.connectivity_service); final android.net.networkinfo wifi =connmgr.getnetworkinfo(connectivitymanager.type_wifi); final android.net.networkinfo mobile =connmgr.getnetworkinfo(connectivitymanager.type_mobile); if(wifi.isavailable()||mobile.isavailable()) return true; else return false; }
Comments
Post a Comment