Home > Net >  When should I use JobService in BroadCastReceiver.onReceive()?
When should I use JobService in BroadCastReceiver.onReceive()?

Time:09-26

I am reading the BroadcastReceiver.onReceive() documentation but I do not understand

If you need to perform any follow up background work, schedule a JobService with JobScheduler

I would be glad if someone could tell me what are the use-cases of such an approach.

Thank you in advance.

CodePudding user response:

BroadcastReceiver may cause an ANR if the work inside onReceive takes a considerable amount of time. Because of that, you should consider moving long-running jobs to the worker, such as JobService, or using jetpack WorkManager.

  • Related