我怎样才能发现,如果一个设备有一个振动器? [英] How can I find out if a device has a vibrator?

查看:100
本文介绍了我怎样才能发现,如果一个设备有一个振动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设备,而我不知道它是否有振动。

有没有一种方法来查询振动器的可用性?

解决方案

振动器 类就是这样做的。这是<一href="http://developer.android.com/reference/android/os/Vibrator.html#hasVibrator%28%29"><$c$c>hasVibrator()方法返回一个布尔值,表示是否支持振动。

  1. 获取其是系统服务的振动器类的一个实例。
  2. 使用 hasVibrator查询振动器类()方法。

字符串VS = Context.VIBRATOR_SERVICE; 振动器mVibrator =(震动)getSystemService(VS); 布尔isVibrator = mVibrator.hasVibrator();

I have a device of which I don't know if it has a vibrator.

Is there a way to query for the availability of the vibrator?

解决方案

The Vibrator class does just that. It's hasVibrator() method returns a boolean indicating if vibrating is supported.

  1. Get an instance of the Vibrator class which is a system service.
  2. Query the Vibrator class using the hasVibrator() method.

String vs = Context.VIBRATOR_SERVICE;
Vibrator mVibrator = (Vibrator)getSystemService(vs);

boolean isVibrator = mVibrator.hasVibrator();

这篇关于我怎样才能发现,如果一个设备有一个振动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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