0

I'd like to set the ringer mode to silent for specific events in the future. It should only happen if a checkbox in the preferences is checked. I know that I have to update the manifest for the permissions and also that I can set the ringer mode with something like this:

if (getPreferences(MODE_PRIVATE).getBoolean(PREFS_KEY_SILENTOPTION, false)) {
   AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
   audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

But how can I set (and reset) it for a space of time in the future?

tshepang
  • 12,111
  • 21
  • 91
  • 136
cody
  • 6,389
  • 15
  • 52
  • 77

1 Answers1

2

Check out the AlarmManager. It allows you to "schedule your application to be run at some point in the future".

Colin O'Dell
  • 8,386
  • 8
  • 38
  • 75