Search code examples
androidalarmmanager

Setting android alarms from a website


I am very new to android programming and I have been asked if it was possible to write both a website and an android app to interface with it. The request is to be able to log into the website and set an alarm or series of alarms to be sent to the android app, possibly with custom music specific to these alerts to be sent to the phone. Is this something that is even possible? I have searched for a while and I can't find any information on setting alarms from websites. Any info would be greatly appreciated. Thanks!


Solution

  • While you can't set an alarm directly from the website, you could manage alarms on the website and have the phone poll the site for alarms.

    Basically, you're setting up a simple web service:

    • Set up a website with login credentials
    • Maintain a database of alarms each user has set from the site
    • Have the app make a request to the site(using credentials)
    • Site returns alarm data for that user(time, date, and path to download custom sound if needed)
    • App sets up alarm using AlarmManager, etc

    I'm not sure how often you're planning on doing updates, though. If you need real-time updates, you might be able to send a push notification(there are a few services for this). If not, you might just want to run a Service that polls it every thirty minutes, etc.