Workmanager在MI,OPPO和VIVO设备中不起作用

时间:2019-12-31 06:25:04

标签: android kotlin background android-workmanager

我使用PeriodicWorkRequest创建了定期请求。它适用于所有期望MI,OPPO和VIVO的设备。

private var mPeriodicWorkRequest: PeriodicWorkRequest? = null
mPeriodicWorkRequest = PeriodicWorkRequest
            .Builder(MyPeriodicWork::class.java, 30, TimeUnit.MINUTES,15, TimeUnit.MINUTES)
            .addTag("periodicWorkRequest")
            .build()

        WorkManager.getInstance().enqueue(mPeriodicWorkRequest!!)

MyPeriodicWork类---

class MyPeriodicWork(workerParams: WorkerParameters?) : Worker( workerParams!!) {

  override fun doWork(): Result {
        Log.e(TAB, "PeriodicWork in BackGround")
        return Result.success()
    }
}

0 个答案:

没有答案