Search code examples
androidtimetime-management

Android Programming execute function at determined time


I am developing a project in Android and I would like to do the following: at a time determined by the user, like 15:40 for example, I would call a function to change the cellphone to silent mode. How can I set it so this function would be called only in this determined time?


Solution

  • Use AlarmManager to trigger a WakefulBroadcastReceiver that can either do your work directly (if it is cheap) or delegate the work to an IntentService (if the work is expensive). The "function" would go in the receiver or the service.