Is it not possible to have a code in the background who will be called every 24h? [closed]

Solution 1:

Edit April 22, 2019:

Recently, Google Cloud released Cloud Scheduler, which allows you to schedule HTTP requests or Cloud Pub/Sub messages to functions that you deploy.

This new service works also very well with Firebase and for that I recommend you read an excellent article writen by Doug Stevenson on the Firebase blog named Scheduling Cloud Functions for Firebase (cron).


Is it not possible to have a code in the "background" who will be called every 24h?

Yes, it is possible. In this case, you should write a function in Cloud Functions for Firebase and call it whenever you needed. If you want to be triggred every 24 hours, use the follwing service:

  • https://cron-job.org/en/

This means that you can do that particular calculation even if the user has the app closed. For a code example, please see Frank van Puffelen's answer from the following post:

  • Cloud Functions for Firebase trigger on time?

Solution 2:

For your case I'd recommend using default Android tools for scheduling jobs. You can try using a new WorkManager or just a JobScheduler. Also you can try digging into this article to get more information.