Fix restarting worker

This commit is contained in:
sim 2022-02-28 22:59:51 +01:00
parent d6ef8adea5
commit 4e45108fa8
1 changed files with 3 additions and 1 deletions

View File

@ -31,8 +31,10 @@ class RestartWorker (ctx: Context, params: WorkerParameters) : Worker(ctx, param
override fun doWork(): Result { override fun doWork(): Result {
Log.d(TAG, "Working") Log.d(TAG, "Working")
val currentDate = Calendar.getInstance() val currentDate = Calendar.getInstance()
val restartDate = lastEventDate?.add(Calendar.MINUTE, 15) val restartDate = lastEventDate
restartDate?.add(Calendar.MINUTE, 15)
if (restartDate == null || currentDate.after(restartDate)) { if (restartDate == null || currentDate.after(restartDate)) {
Log.d(TAG, "Restarting")
StartService.startListener(applicationContext) StartService.startListener(applicationContext)
} }
return Result.success() return Result.success()