简体   繁体   English

如何在 Android API 30 设备中使用 Static 广播接收器或类似服务?

[英]How can I use Static Broadcast Receiver or similar service in Android API 30 device?

I want to schedule a task for every minute on my application and want the task to be executed even when the application/activity is not opened in foreground.我想在我的应用程序上每分钟安排一个任务,并希望即使应用程序/活动未在前台打开也能执行该任务。 How can I achieve that?我怎样才能做到这一点? I am running my application on an Android emulator on API 30.我在 API 30 上的 Android 仿真器上运行我的应用程序。

Please use JobScheduler to schedule a job.请使用 JobScheduler 来安排作业。 From the documentation of Android Job Scheduler is an "API for scheduling various types of jobs against the framework that will be executed in your application's own process."从 Android 的文档来看,Job Scheduler 是一个“用于针对将在您的应用程序自己的进程中执行的框架调度各种类型的作业的 API”。

Detailed documentation here: https://developer.android.com/reference/android/app/job/JobScheduler?hl=en此处的详细文档: https://developer.android.com/reference/android/app/job/JobScheduler?hl=en

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

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