gpt4 book ai didi

android - Oreo 无限后台服务,如 Messenger 或 Instagram

转载 作者:行者123 更新时间:2023-11-29 02:28:40 25 4
gpt4 key购买 nike

如何创建没有通知的无限后台服务,例如 Messenger、Instagram 或 HID Mobile Access?

例如,HID Mobile Access 具有无限运行的后台服务,不会被系统终止,没有通知,并且当应用程序从最近的应用程序列表中删除时不会重新启动。

是否有任何技巧可以做到这一点,或者是否有 Google 非官方支持的应用程序?

最佳答案

一个选项是您可以使用 Work Manager安排任务并在后台运行它们。

The task is still guaranteed to run, even if your app is force-quit or the device is rebooted.

下面是一个运行重复任务的例子:

new PeriodicWorkRequest.Builder photoCheckBuilder =
new PeriodicWorkRequest.Builder(PhotoCheckWorker.class, 12,
TimeUnit.HOURS);
// ...if you want, you can apply constraints to the builder here...

// Create the actual work object:
PeriodicWorkRequest photoCheckWork = photoCheckBuilder.build();
// Then enqueue the recurring task:
WorkManager.getInstance().enqueue(photoCheckWork);

关于android - Oreo 无限后台服务,如 Messenger 或 Instagram,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50797077/

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