AlarmManager, BroadcastReceiver and Service not working

前端 未结 3 1240
时光取名叫无心
时光取名叫无心 2021-01-04 05:45

I\'m refactoring some code so that my app will pull data from a website once a day at a given time. From my research, it seems like AlarmManager is the most app

3条回答
  •  感动是毒
    2021-01-04 06:30

    Instead of using

    Intent dailyUpdater = new Intent(context, MyService.class);

    use

    Intent dailyUpdater = new Intent(this, MyService.class);

    Other suggestion is to start service directly from alarm rather than sending a broadcast and starting the service in broadcast receiver.

提交回复
热议问题