本文整理汇总了Java中android.media.AudioManager.setVibrateSetting方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.setVibrateSetting方法的具体用法?Java AudioManager.setVibrateSetting怎么用?Java AudioManager.setVibrateSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.setVibrateSetting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemClick
import android.media.AudioManager; //导入方法依赖的package包/类
public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
AudioManager manager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
if (manager != null) {
int ringerMode = AudioManager.RINGER_MODE_NORMAL;
int vibroMode = AudioManager.VIBRATE_SETTING_ON;
switch(index) {
case 0: // silent
ringerMode = AudioManager.RINGER_MODE_SILENT;
vibroMode = AudioManager.VIBRATE_SETTING_ONLY_SILENT;
break;
case 1: // vibro
ringerMode = AudioManager.RINGER_MODE_VIBRATE;
vibroMode = AudioManager.VIBRATE_SETTING_ON;
break;
case 2: // sound
ringerMode = AudioManager.RINGER_MODE_NORMAL;
vibroMode = AudioManager.VIBRATE_SETTING_OFF;
break;
case 3: // sound and vibro
ringerMode = AudioManager.RINGER_MODE_NORMAL;
vibroMode = AudioManager.VIBRATE_SETTING_ON;
break;
}
// update manager modes
// update
manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, vibroMode);
manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, vibroMode);
manager.setRingerMode(ringerMode);
validateState(manager);
}
mDialog.hide();
}