我使用下面的代码来振动设备。
public void vibrator() {
try {
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(5000);
} catch (Exception e) {
Log.d(TAG, "vibrator exception: " + e);
}
}
我们能否以编程方式检测此事件(检查设备是否振动)?
最佳答案
不,你不能。
同样的问题是here .
您只能检查是否支持设备振动:
Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
boolean hasVibrator = mVibrator.hasVibrator();
查看更多:
关于android - 检测设备是否振动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29862965/