Android: IntentService or JobScheduler?. Use JobIntentService instead (Part 1)

Image for post
Image for post
Source: https://andro4all.com/files/2018/01/android-tired-700x394.jpg
Image for post
Image for post
(Source: https://developer.android.com/reference/android/app/IntentService)

How to face and solve this issue?

// Old code:
class MyIntentService : IntentService("MyIntentService") { ...
// New Code
class MyIntentService : JobIntentService() { ...
// Old code
override fun onHandleIntent(intent: Intent?) {
// New Code
override fun onHandleWork(intent: Intent) {
const val INTENT_SERVICE_ID = 1003
// Old code
context.startService(intent)
// New code
enqueueWork(context, MyIntentService::class.java, INTENT_SERVICE_ID, intent)
// Permission to add
android:permission="android.permission.BIND_JOB_SERVICE"
// Old code
<service
android:name=".MyIntentService"
android:exported="false" />
// New code
<service
android:name=".MyIntentService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" />
Image for post
Image for post
Source: https://i.kym-cdn.com/entries/icons/original/000/002/686/Deal_with_it_dog_gif.gif

Android Lead, Kotlin developer & Blogger

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store