AudioManager.setStreamVolume的flags参数可选值

以下摘自AudioManager.java,flags参数可选值可以为0或以下的组合

// Flags should be powers of 2!

/**
 * Show a toast containing the current volume.
 *
 * @see #adjustStreamVolume(int, int, int)
 * @see #adjustVolume(int, int)
 * @see #setStreamVolume(int, int, int)
 * @see #setRingerMode(int)
 */
public static final int FLAG_SHOW_UI = 1 << 0;

/**
 * Whether to include ringer modes as possible options when changing volume.
 * For example, if true and volume level is 0 and the volume is adjusted
 * with {@link #ADJUST_LOWER}, then the ringer mode may switch the silent or
 * vibrate mode.
 * <p>
 * By default this is on for the ring stream. If this flag is included,
 * this behavior will be present regardless of the stream type being
 * affected by the ringer mode.
 *
 * @see #adjustVolume(int, int)
 * @see #adjustStreamVolume(int, int, int)
 */
public static final int FLAG_ALLOW_RINGER_MODES = 1 << 1;

/**
 * Whether to play a sound when changing the volume.
 * <p>
 * If this is given to {@link #adjustVolume(int, int)} or
 * {@link #adjustSuggestedStreamVolume(int, int, int)}, it may be ignored
 * in some cases (for example, the decided stream type is not
 * {@link AudioManager#STREAM_RING}, or the volume is being adjusted
 * downward).
 *
 * @see #adjustStreamVolume(int, int, int)
 * @see #adjustVolume(int, int)
 * @see #setStreamVolume(int, int, int)
 */
public static final int FLAG_PLAY_SOUND = 1 << 2;

/**
 * Removes any sounds/vibrate that may be in the queue, or are playing (related to
 * changing volume).
 */
public static final int FLAG_REMOVE_SOUND_AND_VIBRATE = 1 << 3;

/**
 * Whether to vibrate if going into the vibrate ringer mode.
 */
public static final int FLAG_VIBRATE = 1 << 4;

/**
 * Indicates to VolumePanel that the volume slider should be disabled as user
 * cannot change the stream volume
 * @hide
 */
public static final int FLAG_FIXED_VOLUME = 1 << 5;

/**
 * Indicates the volume set/adjust call is for Bluetooth absolute volume
 * @hide
 */
public static final int FLAG_BLUETOOTH_ABS_VOLUME = 1 << 6;

/**
 * Adjusting the volume was prevented due to silent mode, display a hint in the UI.
 * @hide
 */
public static final int FLAG_SHOW_SILENT_HINT = 1 << 7;

/**
 * Indicates the volume call is for Hdmi Cec system audio volume
 * @hide
 */
public static final int FLAG_HDMI_SYSTEM_AUDIO_VOLUME = 1 << 8;

/**
 * Indicates that this should only be handled if media is actively playing.
 * @hide
 */
public static final int FLAG_ACTIVE_MEDIA_ONLY = 1 << 9;

/**
 * Like FLAG_SHOW_UI, but only dialog warnings and confirmations, no sliders.
 * @hide
 */
public static final int FLAG_SHOW_UI_WARNINGS = 1 << 10;

/**
 * Adjusting the volume down from vibrated was prevented, display a hint in the UI.
 * @hide
 */
public static final int FLAG_SHOW_VIBRATE_HINT = 1 << 11;

/**
 * Adjusting the volume due to a hardware key press.
 * @hide
 */
public static final int FLAG_FROM_KEY = 1 << 12;

private static final String[] FLAG_NAMES = {
    "FLAG_SHOW_UI",
    "FLAG_ALLOW_RINGER_MODES",
    "FLAG_PLAY_SOUND",
    "FLAG_REMOVE_SOUND_AND_VIBRATE",
    "FLAG_VIBRATE",
    "FLAG_FIXED_VOLUME",
    "FLAG_BLUETOOTH_ABS_VOLUME",
    "FLAG_SHOW_SILENT_HINT",
    "FLAG_HDMI_SYSTEM_AUDIO_VOLUME",
    "FLAG_ACTIVE_MEDIA_ONLY",
    "FLAG_SHOW_UI_WARNINGS",
    "FLAG_SHOW_VIBRATE_HINT",
    "FLAG_FROM_KEY",
};

/** @hide */
public static String flagsToString(int flags) {
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < FLAG_NAMES.length; i++) {
        final int flag = 1 << i;
        if ((flags & flag) != 0) {
            if (sb.length() > 0) {
                sb.append(',');
            }
            sb.append(FLAG_NAMES[i]);
            flags &= ~flag;
        }
    }
    if (flags != 0) {
        if (sb.length() > 0) {
            sb.append(',');
        }
        sb.append(flags);
    }
    return sb.toString();
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值