]> gitweb.stoutner.com Git - PrivacyCell.git/blob - app/src/main/java/com/stoutner/privacycell/workers/RestartServiceWorker.kt
Release 1.7.
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / workers / RestartServiceWorker.kt
1 /*
2  * Copyright © 2021 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell>.
5  *
6  * Privacy Cell is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Privacy Cell is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Privacy Cell.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 package com.stoutner.privacycell.workers
21
22 import android.content.Context
23 import android.content.Intent
24
25 import androidx.work.Worker
26 import androidx.work.WorkerParameters
27 import com.stoutner.privacycell.services.RealtimeMonitoringService
28
29 class RestartServiceWorker(appContext: Context, workerParameters: WorkerParameters) : Worker(appContext, workerParameters) {
30     override fun doWork(): Result {
31         // Start the realtime monitoring service as a foreground service, which is required because the worker is running in the background.
32         applicationContext.startForegroundService(Intent(applicationContext, RealtimeMonitoringService::class.java))
33
34         // Return a success.
35         return Result.success()
36     }
37 }