本文整理汇总了Java中android.media.AudioManager.getVibrateSetting方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.getVibrateSetting方法的具体用法?Java AudioManager.getVibrateSetting怎么用?Java AudioManager.getVibrateSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.getVibrateSetting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRingerMode
import android.media.AudioManager; //导入方法依赖的package包/类
public void updateRingerMode() {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
synchronized (this) {
int ringerMode = audioManager.getRingerMode();
// Silent : stop everything
if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
stopRing();
return;
}
// Vibrate
int vibrateSetting = audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
// If not already started restart it
if (vibratorThread == null && (vibrateSetting == AudioManager.VIBRATE_SETTING_ON || ringerMode == AudioManager.RINGER_MODE_VIBRATE)) {
vibratorThread = new VibratorThread();
vibratorThread.start();
}
// Vibrate only
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE || audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
stopRinger();
return;
}
//Ringer
ringerWorker.startRinging(audioManager);
}
}
示例2: updateState
import android.media.AudioManager; //导入方法依赖的package包/类
private void updateState() {
final AudioManager manager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
if (manager == null) return;
int ringer = manager.getRingerMode();
int vibro = manager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
int descr; int icon; boolean silent = false;
if (ringer == AudioManager.RINGER_MODE_SILENT) {
descr = R.string.txt_ringer_silent;
icon = R.drawable.ic_silent;
silent = true;
} else if (ringer == AudioManager.RINGER_MODE_NORMAL) {
if (vibro == AudioManager.VIBRATE_SETTING_ON) {
descr = R.string.txt_ringer_vibrosound;
icon = R.drawable.ic_vibro_sound;
} else {
descr = R.string.txt_ringer_sound;
icon = R.drawable.ic_sound;
}
} else {
descr = R.string.txt_ringer_vibro;
icon = R.drawable.ic_vibro;
}
// update setting values
Setting setting = mSetting;
setting.descr = mActivity.getString(descr);
setting.iconId = icon;
setting.checked = !silent;
setting.updateView();
}
示例3: ring
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* Starts the ringtone and/or vibrator.
*
*/
public void ring(String remoteContact, String defaultRingtone) {
Log.d(THIS_FILE, "==> ring() called...");
synchronized (this) {
AudioManager audioManager =
(AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
//Save ringtone at the begining in case we raise vol
Ringtone ringtone = getRingtone(remoteContact, defaultRingtone);
ringerWorker.setRingtone(ringtone);
//No ring no vibrate
int ringerMode = audioManager.getRingerMode();
if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
Log.d(THIS_FILE, "skipping ring and vibrate because profile is Silent");
return;
}
// Vibrate
int vibrateSetting = audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
Log.d(THIS_FILE, "v=" + vibrateSetting + " rm=" + ringerMode);
if (vibratorThread == null &&
(vibrateSetting == AudioManager.VIBRATE_SETTING_ON ||
ringerMode == AudioManager.RINGER_MODE_VIBRATE)) {
vibratorThread = new VibratorThread();
Log.d(THIS_FILE, "Starting vibrator...");
vibratorThread.start();
}
// Vibrate only
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE ||
audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0 ) {
Log.d(THIS_FILE, "skipping ring because profile is Vibrate OR because volume is zero");
return;
}
// Ringer normal, audio set for ring, do it
if(ringtone == null) {
Log.d(THIS_FILE, "No ringtone available - do not ring");
return;
}
ringerWorker.startRinging(audioManager);
}
}