代码之家  ›  专栏  ›  技术社区  ›  Pentium10

How can we get notified if the phone has got internet access?

  •  11
  • Pentium10  · 技术社区  · 14 年前

    Is there a broadcast receiver or some kind of setting that we can listen/monitor to get notified if the internet/network has been connected.

    1 回复  |  直到 14 年前
        1
  •  13
  •   drawnonward    14 年前

    倾听 CONNECTIVITY_ACTION

    这看起来不错 sample code . Here is a snippet:

            IntentFilter filter = new IntentFilter();
            filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
            context.registerReceiver(mReceiver, filter);