Android, Silent mode notification

前端 未结 1 678
无人共我
无人共我 2021-01-21 17:55

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

相关标签:
1条回答
  • 2021-01-21 18:39

    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

    0 讨论(0)
提交回复
热议问题