I have created a client-server wi-fi app. The problem is when server connection is lost, it does not throws any IO Exception during read/write operation in socket. How can i identify that the server connection was lost wit开发者_如何学Chin my app?
Thanks in advance.
you can use this
private boolean checkInternetConnection()
{
ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
return conMgr.getActiveNetworkInfo().isConnectedOrConnecting();
}
I hope it will help you.
精彩评论