How can I find out if a device has a vibrator?

后端 未结 4 1107
臣服心动
臣服心动 2021-01-03 17:58

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?

4条回答
  •  [愿得一人]
    2021-01-03 18:19

    This may help for API<11:

    Context.getSystemService() returns a service object or null if no service.

    if ( getSystemService(VIBRATOR_SERVICE) != null ) {
        //Vibrator exists
    }
    

提交回复
热议问题