'I'm trying to develop an android and I need some advices

I'm trying to develop an app that retrieves from firebase the state of electric doors in some different cities and if a door error exists in any city, the app would automatically call or send SMS to the manager of that specific city based on the phone number saved in the db and this app should work in the background as well, I think I must start a foreground service but I wasn't so sure because I'm a beginner, could anyone advice me please. here's my db structure db.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source