문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top