Android 设置声音时出现按键音
2015-11-14 15:14
465 查看
static AudioManager tMyAudioManager;
tMyAudioManager = (AudioManager) tMyContext.getSystemService(Context.AUDIO_SERVICE);
tMyAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, tInputVal, AudioManager.FLAG_PLAY_SOUND);
每次调用setStreamVolume时都会出现按键音,查了一下AudioMabager.java后来发现是第三个参数的原因
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;
/**
* Ringer mode that will be silent and will not vibrate. (This overrides the
* vibrate setting.)
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_SILENT = 0;
/**
* Ringer mode that will be silent and will vibrate. (This will cause the
* phone ringer to always vibrate, but the notification vibrate to only
* vibrate if set.)
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_VIBRATE = 1;
/**
* Ringer mode that may be audible and may vibrate. It will be audible if
* the volume before changing out of this mode was audible. It will vibrate
* if the vibrate setting is on.
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_NORMAL = 2;
// maximum valid ringer mode value. Values must start from 0 and be contiguous.
private static final int RINGER_MODE_MAX = RINGER_MODE_NORMAL;
/**
* Vibrate type that corresponds to the ringer.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_TYPE_RINGER = 0;
/**
* Vibrate type that corresponds to notifications.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_TYPE_NOTIFICATION = 1;
/**
* Vibrate setting that suggests to never vibrate.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_OFF = 0;
/**
* Vibrate setting that suggests to vibrate when possible.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_ON = 1;
/**
* Vibrate setting that suggests to only vibrate when in the vibrate ringer
* mode.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_ONLY_SILENT = 2;
/**
* Suggests using the default stream type. This may not be used in all
* places a stream type is needed.
*/
public static final int USE_DEFAULT_STREAM_TYPE = Integer.MIN_VALUE;
tMyAudioManager = (AudioManager) tMyContext.getSystemService(Context.AUDIO_SERVICE);
tMyAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, tInputVal, AudioManager.FLAG_PLAY_SOUND);
每次调用setStreamVolume时都会出现按键音,查了一下AudioMabager.java后来发现是第三个参数的原因
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;
/**
* Ringer mode that will be silent and will not vibrate. (This overrides the
* vibrate setting.)
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_SILENT = 0;
/**
* Ringer mode that will be silent and will vibrate. (This will cause the
* phone ringer to always vibrate, but the notification vibrate to only
* vibrate if set.)
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_VIBRATE = 1;
/**
* Ringer mode that may be audible and may vibrate. It will be audible if
* the volume before changing out of this mode was audible. It will vibrate
* if the vibrate setting is on.
*
* @see #setRingerMode(int)
* @see #getRingerMode()
*/
public static final int RINGER_MODE_NORMAL = 2;
// maximum valid ringer mode value. Values must start from 0 and be contiguous.
private static final int RINGER_MODE_MAX = RINGER_MODE_NORMAL;
/**
* Vibrate type that corresponds to the ringer.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_TYPE_RINGER = 0;
/**
* Vibrate type that corresponds to notifications.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @see #shouldVibrate(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_TYPE_NOTIFICATION = 1;
/**
* Vibrate setting that suggests to never vibrate.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_OFF = 0;
/**
* Vibrate setting that suggests to vibrate when possible.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_ON = 1;
/**
* Vibrate setting that suggests to only vibrate when in the vibrate ringer
* mode.
*
* @see #setVibrateSetting(int, int)
* @see #getVibrateSetting(int)
* @deprecated Applications should maintain their own vibrate policy based on
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public static final int VIBRATE_SETTING_ONLY_SILENT = 2;
/**
* Suggests using the default stream type. This may not be used in all
* places a stream type is needed.
*/
public static final int USE_DEFAULT_STREAM_TYPE = Integer.MIN_VALUE;
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories