相关文章推荐
力能扛鼎的筷子  ·  sql foreach用法-掘金·  10 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

The JobIntentService class appears to be deprecated. Yet the Android documentation for services says: "You can use JobIntentService as a replacement for IntentService that is compatible with newer versions of Android."

So what are we supposed to replace JobIntentService with?

WorkManager would be one candidate. It may depend on what the IntentService / JobIntentService is supposed to do. CommonsWare Aug 7, 2021 at 20:56 Then IntentService and JobIntentService were never viable candidates. Use a plain Service , one with a foreground notification for your countdown timer. CommonsWare Aug 12, 2021 at 18:42 Does anyone know what is meant by: "This class has been deprecated in favor of the Android Jetpack Android O or later"? It seems to me to not be proper language and possibly wrong? Simon Malone Sep 27, 2021 at 9:15 WTH is android team doing? Why even give us IntentService > JobIntentService and now WorkManager if you are going to deprecate one day. Only they know when workmanager is being deprecated too. Alex Apr 1, 2022 at 3:44 Classic Googlers. IntentService worked just fine! Since they forced us to migrate to JobIntentService on Oreo, background processes do not work reliably ( stackoverflow.com/questions/63111658/… ). And now they even deprecated JobIntentService , replaced with WorkManager which - suprise surprise - also does not work reliably and probably is gonna be deprecated soon either way. Omfg Google, do you even think before you do something????? Incompenent idiots...Argh. qkx Jul 5, 2022 at 10:10

As @CommonsWare pointed out, I had two options for replacing my JobIntentService:

  • Using a foreground service
  • Using a WorkManager with a long-running worker
  • The Android documentation on services states:

    The WorkManager API offers a flexible way of scheduling tasks, and is able to run these jobs as foreground services if needed. In many cases, using WorkManager is preferable to using foreground services directly.

    Since Google seems to be pushing folks towards WorkManager, that's what I decided to use.

    WorkManager seems to be used for persistent work. I don't need persistence but simply a replacement for IntentService. What should I choose? JohnyTex Mar 28, 2022 at 9:21 @JohnyText how about using Service with a new Thread inside it to execute background work Krot Apr 11, 2022 at 5:15 which of these options would be more appropriate (= reliable) for updating home screen widgets ( RemoteViews ) on the background? I have a problem, that my widgets sometimes do not update, because JobIntentService does not work reliably, see here: stackoverflow.com/questions/63111658/… qkx Jul 5, 2022 at 10:16 WorkManager don't have extras like Services/JobIntentService (Intent). It won't be favorable for API like activity recognition androidXP Oct 7, 2022 at 1:04

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .