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.
hasVibrator() method.String vs = Context.VIBRATOR_SERVICE;
Vibrator mVibrator = (Vibrator)getSystemService(vs);
boolean isVibrator = mVibrator.hasVibrator();
This may help for API<11:
Context.getSystemService() returns a service object or null if no service.
if ( getSystemService(VIBRATOR_SERVICE) != null ) {
//Vibrator exists
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With