Broadcast receiver for checking internet connection in android app

后端 未结 21 3194
温柔的废话
温柔的废话 2020-11-21 22:28

I am developing an android broadcast receiver for checking internet connection.

The problem is that my broadcast receiver is being called two times. I want it to get

21条回答
  •  粉色の甜心
    2020-11-21 22:33

    CONNECTIVITY_ACTION docs:

    Apps targeting Android 7.0 (API level 24) and higher do not receive this broadcast if they declare the broadcast receiver in their manifest. Apps will still receive broadcasts if they register their BroadcastReceiver with Context.registerReceiver() and that context is still valid.

提交回复
热议问题