AudioManager.STREAM_ALARM拒绝静音或取消静音

时间:2017-10-17 02:04:00

标签: android audio

我在Kotlin的API 23下运行此代码:

fun handleStreamButton(id: Int, streamID: Int) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            debugOut("handleStreamButton(): Build.VERSION.SDK_INT >= Build.VERSION_CODES.M")
        } else {
            debugOut("handleStreamButton(): Build.VERSION.SDK_INT < Build.VERSION_CODES.M")
    }

    var tb: ToggleButton = getToggleButton(id)
    var toMute = getToggleButtonState(tb)
    var muteAction = AudioManager.ADJUST_UNMUTE

    if (toMute) {
        muteAction = AudioManager.ADJUST_MUTE
    }

    var before = audioManager.isStreamMute(streamID);

    audioManager.adjustStreamVolume(
            streamID,
            muteAction,
            0)
   /*
    * deprecated, but worth a try. No joy.
      audioManager.setStreamMute(streamID, toMute)
    */

    var after = audioManager.isStreamMute(streamID);
    debugOut("handleStreamButton(): before: " + before + "; after: " + after)

} // handleStreamButton

STREAM_MUSIC,STREAM_NOTIFICATION,STREAM_RING一切正常。

但是,STREAM_ALARM拒绝将状态从静音状态更改为非静音状态或vv。

有些问题不是问题:

  1. android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS
  2. 多个静音需要多次取消静音
  3. 任何帮助?

0 个答案:

没有答案