[英]how to schedule a foreground service with job Scheduler in android
My app shows the user a way to schedule some work(background heavy work). 我的应用程序向用户显示了安排一些工作(背景繁重的工作)的方法。 and I want to do it in foreground service at midnight(or some other time that chooses by the user). 我想在午夜(或由用户选择的其他时间)在前台服务中执行此操作。
I think the Android Jetpack component called WorkManager is for you : 我认为名为WorkManager的Android Jetpack组件适合您:
documentation : https://developer.android.com/topic/libraries/architecture/workmanager 文档: https : //developer.android.com/topic/libraries/architecture/workmanager
codelab : https://codelabs.developers.google.com/codelabs/android-workmanager/#0 codelab: https ://codelabs.developers.google.com/codelabs/android-workmanager/#0
I recomend using work manager instead. 我建议改用工作管理器 。 Its more suited for such task, and is more modern aproach to background processing which with new android devices become more limited (by doze mode, etc.). 它更适合此类任务,并且对后台处理的处理方式更现代,而随着新的android设备的使用,该处理方式变得更加受限制(通过打ze模式等)。
If you need to schedule your work at specified time then you schould rather choose AlarmManager - see this so: Schedule a work on a specific time with WorkManager 如果您需要在指定时间安排工作,则应该选择AlarmManager-参见以下内容: 使用WorkManager在特定时间安排工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.