最終更新:2021-10-18 (月) 13:32:44 (919d)  

Android/音量
Top / Android / 音量

https://developer.android.com/guide/topics/media-apps/volume-and-earphones?hl=ja

メモ

  • デフォルトでは、音量コントロールを押すと、アクティブな音声ストリームの音量が変更されます。
  • アプリで何も再生していない場合は、音量ボタンを押すと音楽(Android 9 より前では着信音)の音量が調整されます。

クラス

ストリーム

  • AudioManager.STREAM_VOICE_CALL?0通話音量
    AudioManager.STREAM_SYSTEM?1システムメッセージ音量
    AudioManager.STREAM_RING?2着信音量
    AudioManager.STREAM_MUSIC3音楽再生音量
    AudioManager.STREAM_ALARM?4アラーム音量
    AudioManager.STREAM_NOTIFICATION?5通知音量
    AudioManager.STREAM_DTMF?8ダイヤル音量

変更

メイン

  • Activity.setVolumeControlStream?

その他

  • AudioManager.adjustStreamVolume(int streamType, int direction, int flags)Adjusts the volume of a particular stream by one step in a direction.
    AudioManager.adjustSuggestedStreamVolume?(int direction, int suggestedStreamType?, int flags)Adjusts the volume of the most relevant stream, or the given fallback stream.
    AudioManager.adjustVolume?(int direction, int flags)Adjusts the volume of the most relevant stream.
    AudioManager.setStreamVolume(int streamType, int index, int flags)Sets the volume index for a particular stream.
    AudioManager.setStreamSolo?(int streamType, boolean state)This method was deprecated in API level 23. Do not use.
    AudioManager.setStreamMuteThis method was deprecated in API level 23. Use AudioManager.adjustStreamVolume

フラグ

  • AudioManager.FLAG_SHOW_UI1Show a toast containing the current volume.
    AudioManager.FLAG_ALLOW_RINGER_MODES?2Whether to include ringer modes as possible options when changing volume.
    AudioManager.FLAG_PLAY_SOUND4Whether to play a sound when changing the volume
    AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE?8Removes any sounds/vibrate that may be in the queue, or are playing (related to changing volume).
    AudioManager.FLAG_VIBRATE?16Whether to vibrate if going into the vibrate ringer mode.
    AudioManager.FLAG_FIXED_VOLUME?1 << 5@hide
    AudioManager.FLAG_BLUETOOTH_ABS_VOLUME?1 << 6@hide
    AudioManager.FLAG_SHOW_SILENT_HINT?1 << 7@hide
    AudioManager.FLAG_HDMI_SYSTEM_AUDIO_VOLUME?1 << 8@hide
    AudioManager.FLAG_ACTIVE_MEDIA_ONLY?1 << 9@hide
    AudioManager.FLAG_SHOW_UI_WARNINGS?1 << 10@hide
    AudioManager.FLAG_SHOW_VIBRATE_HINT?1 << 11@hide
    AudioManager.FLAG_FROM_KEY?1 << 12@hide

キーコード定義

メモ

  • Android/バージョン仕様
    ~2.3.7「着信音量」と「通知音量」は個別に設定可能です。
    4.X (4.0~4.4)「着信音量」と「通知音量」が同じ音量設定です。
    5.0~6.0「着信音量」と「通知音量」と「システム音量」が同じ音量設定です。

参考