gpt4 book ai didi

android - BroadcastReceiver 与服务

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:09 24 4
gpt4 key购买 nike

那么,在 android 中,在 broadcastReceiver 中做某事在 broadcastReceiver 中调用另一个服务 有什么区别?我认为它们都在后台运行,对吧?

其实我要做的是:

In certain time of everyday, download the user event(eg: 9:00 am eat breakfast) from database, and set up the AlarmManager to show notification about the event.

现在我设置了一个警报管理器来完成上述任务。我很困惑,我应该直接在 BroadcastReceiver 中完成此操作还是在 BroadcastReceiver 中调用服务来完成此操作。

谢谢。

最佳答案

你应该在 BroadcastReceiver 中做尽可能少的处理,因为(引用自 Android Blog )

When handling a broadcast, the application is given a fixed set of time (currently 10 seconds) in which to do its work. If it doesn't complete in that time, the application is considered to be misbehaving, and its process immediately tossed into the background state to be killed for memory if needed.

关于android - BroadcastReceiver 与服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7460284/

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