检测设备是否振动? [英] Detect the device is vibrating?

查看:209
本文介绍了检测设备是否振动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have used the below code to vibrate the device.

public void vibrator() {
    try {
        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(5000);
    } catch (Exception e) {
        Log.d(TAG, "vibrator exception: " + e);
    }
}

我们可以以编程方式检测这个事件(检查是设备振动)?

Can we programmatically detect this event (check is device vibrating)?

推荐答案

不,你不能。

问题是这里

你只能支持振动设备:

Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
boolean hasVibrator = mVibrator.hasVibrator();

查看更多:

  • Android Vibrator

这篇关于检测设备是否振动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆