简体   繁体   English

在动态注册广播接收器的onReceive方法时,它总是被调用吗?

[英]Is a BroadcastReceiver's onReceive method always called the moment it gets registered dynamically?

I noticed that my wifi state BroadcastReceiver gets triggered everytime I register it in onResume with registerBroadcastReceiver . 我注意到,我的无线状态广播接收器被触发,每次我用它注册在的onResume registerBroadcastReceiver Is that the default behavior? 这是默认行为吗?

Some broadcasts are sticky. 有些广播是粘性的。 This means that they'll 'stick' around after being broadcast so that new receivers immediately receive them when they register. 这意味着它们在广播后会“停留”在周围,以便新接收者在注册后立即接收它们。

An intent that is used with sticky broadcast, is called as sticky intent. 与粘性广播一起使用的意图称为粘性意图。 This intent will stick with android system for future broadcast receiver requests. 此意图将与android系统保持一致,以用于将来的广播接收器请求。

See: https://stackoverflow.com/a/26038927/1810398 参见: https : //stackoverflow.com/a/26038927/1810398

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM