

If yourĪpp uses the Java programming language, you should use RxJava or Guava. Expedite a WorkRequest with setExpedited().įor impersistent immediate work, you should you use Kotlin coroutines. Need to remain scheduled for prompt execution even if the app closes or theįor persistent immediate work, you should use WorkManager with a They are important enough that they might Tasks which are important to the user or which you otherwise can't schedule forĭeferred execution at a later time. Immediate work encompasses tasks which need to execute right away. Instead, perform work persistently using WorkManager. The following table lays out which approach you should take for each type of You should insteadĬomplete such tasks through persistent work using WorkManager. Long-running and deferrable impersistent work.

Guide on threading for recommended options. For Java programming language users, read the

The user subsequently navigates away from Note: Consider a case in which a foreground service starts while an activityįrom the app is visible to the user. Otherwise, the app is running in the foreground. The app isn't running any foreground services that started while anĪctivity from the app was visible to the user.None of the app's activities are currently visible to the user.

Definition of background workĪn app is running in the background when both the following conditions are Working on a machine learning (ML) model, or performing network requests. Long-running tasks include things like decoding a bitmap, accessing storage, In general, you should take any blocking tasks off the UI thread. This guide explains what qualifies as background work, defines background taskĬategories, provides you with criteria to categorize your tasks, and recommendsĪPIs that you should use to execute them. Performance and therefore a poor user experience. Doing work on the main thread can lead to poor Processing data in the background is an important part of creating an AndroidĪpplication that is both responsive for your users as well as a good citizen on
