Listen to volume changes events on Android

前端 未结 4 707
梦谈多话
梦谈多话 2020-12-31 09:17

Is there any way to listen to the event of volume change on Android, without just taking over the volume buttons?

The only thing I\'ve found that works is here, but

4条回答
  •  独厮守ぢ
    2020-12-31 09:55

    ok , for now , what i do is to listen to the volume buttons using onKeyDown (and check for KEYCODE_VOLUME_DOWN,KEYCODE_VOLUME_MUTE,KEYCODE_VOLUME_UP ) , and using a handler i've posted a new runnable that checks the volume level .

    also , since some devices have a volume dialog , i've added a listener to when it is being disappeared , according to this link.

提交回复
热议问题