Setting the Android System Volume

前端 未结 2 483
名媛妹妹
名媛妹妹 2021-01-06 09:32

I am writing an application which handles the following:

  1. Silent - Makes the phone volume silent
  2. Low - Makes the phone volume 1 point above the silent<
2条回答
  •  轮回少年
    2021-01-06 10:13

    Check out http://thinkandroid.wordpress.com/2010/04/05/dealing-with-the-android-media-player/

    The steps are:

    • get the audio man.
    • fetch the required stream.
    • call appropriate method on stream.

    e.g.:

    mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
    
    • to get max vol:

      int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
      

提交回复
热议问题