gpt4 book ai didi

android - 注册和注销广播接收器?

转载 作者:行者123 更新时间:2023-11-29 16:41:37 25 4
gpt4 key购买 nike

<分区>

if you register a receiver in onCreate(Bundle) using the activity's context, you should unregister it in onDestroy() to prevent leaking the receiver out of the activity context. If you register a receiver in onResume(), you should unregister it in onPause() to prevent registering it multiple times (If you don't want to receive broadcasts when paused, and this can cut down on unnecessary system overhead).

这是我从官方文档中得到的。为什么我们说“如果我们在 onCreate() 中注册了一个接收器,我们应该在 onDestroy() 中注销它”?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com