Suresh
Suresh

Reputation: 9595

Vibrator in android

How to create Vibrator object and call vibrate function? http://developer.android.com/reference/android/os/Vibrator.html doesn't give much information regarding how to create the object ( no public constructors )

Upvotes: 4

Views: 1519

Answers (2)

Eslam Sameh Ahmed
Eslam Sameh Ahmed

Reputation: 4022

You have to create the object then call the function object.vibrate whith vibration period in milliseconds

Vibrator v = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
// To vibrate for 1 second
v.vibrate(1000);

Upvotes: 0

Felix
Felix

Reputation: 89576

I think you're looking for:

Vibrator bzzz = (Vibrator) getSystemService(VIBRATOR_SERVICE);

See the docs.

Upvotes: 9

Related Questions