Created
April 9, 2021 17:50
-
-
Save avianey/5ac103f9281660f419768dba8108f79e to your computer and use it in GitHub Desktop.
JobIntentService crashing with java.lang.RuntimeException: An error occurred while executing doInBackground()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package androidx.core.app | |
abstract class JobIntentServiceInternal: JobIntentService() { | |
/** | |
* Returns a GenericWorkItem that will fail silently to complete | |
* if it has been cancelled while executing inside | |
* the JobIntentService$CommandProcessor#doInBackground loop | |
* or if dequeue fails | |
*/ | |
override fun dequeueWork(): GenericWorkItem? { | |
try { | |
val item = super.dequeueWork() | |
if (item != null) { | |
return object : GenericWorkItem { | |
override fun getIntent() = item.intent | |
override fun complete() { | |
try { | |
item.complete() | |
} catch (ignore: Exception) {} | |
} | |
} | |
} | |
} catch (ignore: Exception) {} | |
return null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment