BroadcastReceiver declared in manifest is not receiving the Broadcast

前端 未结 7 1922
余生分开走
余生分开走 2020-12-30 04:30

I\'ve tried to register a Wifi BroadcastReceiver to get the wifi state when it changes. But so far I have no luck receiving the broadcast.



        
7条回答
  •  [愿得一人]
    2020-12-30 04:50

    If your Target android version is more than Android O. if you declare receivers in manifest they wont work. So you need to register inside your activity.

    Note: If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for implicit broadcasts (broadcasts that do not target your app specifically), except for a few implicit broadcasts that are exempted from that restriction. In most cases, you can use scheduled jobs instead.

    Resource: https://developer.android.com/guide/components/broadcasts

提交回复
热议问题