How to be notified on wifi network status change?

前端 未结 4 1640
醉梦人生
醉梦人生 2020-11-29 02:16

I am writing an app that connects to a telnet server via wifi. I have a service that manages the socket connection. It all works fine, but when the phone sleeps it disconn

4条回答
  •  天涯浪人
    2020-11-29 03:09

    Not sure as to the exact way to do this but I think the ConnectivityManager would be a good place to start.

    http://developer.android.com/reference/android/net/ConnectivityManager.html

    you can get an instance of this class by calling Context.getSystemService(Context.CONNECTIVITY_SERVICE)

    There are also some other good classes in android.net that you can use.

    Hope that helps.

提交回复
热议问题