Checking internet connection with service on android

后端 未结 3 2074
时光取名叫无心
时光取名叫无心 2020-12-31 19:39

I know how to check for internet connectivity when my app is open using activity. But how to check for connectivity in service when my app is not running?

3条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 20:13

    The system provides a Broadcast when the network connectivity changes, which you can read using a BroadcastReceiver. This will be called whether your app is open or closed.

提交回复
热议问题