Android, Silent mode notification
In my android app I need to know, whenever the user is in Phone options mode (the one that appears when you hold down the power button for a while), and pushes the 'Silent mode' button. I have found that Airplane mode is linked to the ACTION_AIRPLANE_MODE_CHANGED. But I can not find any a开发者_StackOverflow社区ction event for the 'Silent mode' button?
The AudioManager provides a getRingerMode() method which can be used to determine the current state.
In your case you have to query the returned value for AudioManager.RINGER_MODE_SILENT, so something like
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
if (am.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
// do something neat here
}
In combination with AudioManager's RINGER_MODE_CHANGED_ACTION this should work for you
加载中,请稍侯......
精彩评论