android - 检测设备是否振动?

标签 android events android-vibration vibration

我使用下面的代码来振动设备。

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/

相关文章:

javascript - 单击事件不会触发默认操作

android - 当屏幕锁定在代号一中时,使用自定义声音和振动推送通知

android - 如何触发声音输入的振动?

安卓独立包

android - 使用电话号码获取来电国家名称?

javascript - 事件绑定(bind)和修改innerHTML

events - 如何获取主页事件列表?

android - 移动项目的 SLA(服务水平协议(protocol))

android - 如何在 Android 中使高度超过 wrap_content?

android - Activity 完成后停止android中的振动