Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WorkManagerを使っていい塩梅でNotificationをする話

umakoz
March 14, 2019

 WorkManagerを使っていい塩梅でNotificationをする話

umakoz

March 14, 2019
Tweet

More Decks by umakoz

Other Decks in Technology

Transcript

  1. About me • LINE Fukuoka ։ൃ3ࣨ • അݟɹ੣ʢumami makotoʣ •

    @umakoz • LINE Creators Studio for Android • ! 3°02'03"
  2. WorkManager key features 1 • API 14·ͰԼҐޓ׵ੑ͕͋Δ • API 23+ͷDeviceͰ͸JobSchedulerΛ࢖͏

    • API 13-22ͷDeviceͰ͸BroadcastReceiverͱ AlarmManagerΛ૊Έ߹Θͤͯ࢖͏ • Network͕࢖͑Δ͔ͱ͔Battery͕े෼͔ͳͲͷ੍໿Λ͚ͭͯ ࣮ߦͰ͖Δ
  3. class SomeWorker( appContext: Context, workerParams: WorkerParameters ) : Worker(appContext, workerParams)

    { override fun doWork(): Result { // Do the work here return Result.success() } } val request = OneTimeWorkRequest .Builder(SomeWorker::class.java) .setInitialDelay(1, TimeUnit.HOURS) .build() WorkManager.getInstance() .enqueue(request)
  4. class SomeWorker( appContext: Context, workerParams: WorkerParameters ) : Worker(appContext, workerParams)

    { override fun doWork(): Result { // Do the work here return Result.success() } } val request = PeriodicWorkRequest .Builder(SomeWorker::class.java, 1, TimeUnit.HOURS) .build() WorkManager.getInstance() .enqueue(request)