Search code examples
javaandroidalarmmanagersilent

How to build a silent phone app?


I am building an android app that will help users to specify a time frame when the app will put the phone to silent mode. I have been able to achieve the time picker and save the time to the database.

Now, I just need someone to point me to the right direction. I'm thinking of using the alarm manager class but I don't know if this is the approach I should use.


Solution

  • Alarm Manager is perfectly the correct approach to trigger your app activity again and do the necessary work.

    From the reference:

    These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running

    You have to register a broadcast listener for the alarm. In the broadcast listener put all the things you want your app to do.