您是否需要实现 AIDL 才能使服务在应用程序生命周期之外运行?

发布于 2024-10-01 09:25:45 字数 96 浏览 0 评论 0原文

我有一项服务可以发送带有定时任务的通知。我需要此服务在应用程序的生命周期之外运行,但我只需要在应用程序的生命周期内访问服务功能。本地服务就足够了还是我需要实施 AIDL? 谢谢。

I have a service that will send out notifications with timed tasks. I need this service to run outside the life of the application, but I only need to access the services functions during the lifespan of the app. Is a local service enough or do I need to implement AIDL?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜吻♂芭芘 2024-10-08 09:25:46

我有一项服务可以发送带有定时任务的通知。

我希望您指的是 AlarmManagerIntentService,这样您的服务仅在内存中保留尽可能短的时间,足以完成一些工作,提高通知,然后走开。不要编写试图永远存在的服务,因为这是不可能的——用户或操作系统会杀死你的服务。

本地服务就足够了还是我需要实现 AIDL?

通过提出这个问题,我相信您有更根本的问题,例如没有使用 AlarmManagerIntentService 进行定期工作。您的 raise-a-Notification-periodically 服务不应运行,因此不应存在您尝试访问的“服务功能”。

I have a service that will send out notifications with timed tasks.

By this, I hope you mean AlarmManager and an IntentService, such that your service is only in memory for the minimum possible time, enough to do a bit of work, raise the Notification, and go away. Do not write services that attempt to live forever, since that is impossible -- users or the operating system will kill off your service.

Is a local service enough or do I need to implement AIDL?

By asking that question, I believe that you have more fundamental problems, such as not using AlarmManager and an IntentService for your periodic work. Your raise-a-Notification-periodically service should not be running, and hence there should be no "services functions" that you are trying to access on it.

尐籹人 2024-10-08 09:25:46

你不“实现 AIDL” - AIDL(android 接口定义语言)是一种推荐但非强制的便利/抽象机制,用于生成实现 Binder RPC 接口所需的代码,这是与服务通信的推荐但不是唯一的方式。

You do not "implement AIDL" - AIDL (android interface definition LANGUAGE) is a recommended but not mandatory convenience/abstration mechanism for generating the code needed to implement a Binder RPC interface, which is the recommended but not only way of communicating with a service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文