【发布时间】:2019-01-15 13:37:15
【问题描述】:
这个问题是针对小米的。我知道在普通 Android 操作系统上的设备也有类似的问题。
有多种方法可以了解 Android 手机是处于 100% 仅振动模式,还是在正常模式下打开了“通话时振动”。
小米的问题是……没有人工作。至少,从我的列表中:
/**
* This method should tell us if the vibration is on in the Android System settings
*/
public boolean checkVibrationIsOn() {
boolean status = false;
if (isInVibrationMode()
|| isVibrationOnHacky()
|| isVibrationOnDeprecated()) {
status = true;
}
return status;
}
/**
* Check if the phone is in Vibration mode
*/
private boolean isInVibrationMode() {
return audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;
}
/**
* Use a direct access to get status of Vibration. Works not on all kinds of phones
*/
private boolean isVibrationOnHacky() {
return 0 != Settings.System.getInt(context.getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING,0);
}
/**
* Use a deprecated method to get status of Vibration. It was deprecated so usual apps can't use it
* but it works on some devices
*/
private boolean isVibrationOnDeprecated() {
return audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER);
}
有人知道如何在小米设备上查看“振动”类别的“通话时也振动”和“静音模式下振动”标志吗?
【问题讨论】:
标签: android call android-vibration