开发者

android socket connection

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜