2

Is there any event which is fired when the android phone is vibrating so I can subscribe my event handler to it?

Thank you for your time.

1

2 Answers 2

1

You can use Context.getSystemService() to get a Vibrator object. Using that object you can identify whether phone has a vibrator.

Vibrator vibrator  = context.getSystemService(Context.VIBRATOR_SERVICE);

to identfiy whether phone has a vibrator, use hasVibrator()

 vibrator.hasVibrator()

You can start and stop vibration using

vibrate.vibrate(long milliseconds);
vibrate.cancel();

EDIT: After seeing op's comment..

I don't think you will get notification when phone starts vibrating AFAIK. (Happy if someone clears me wrong).. You can find out whether phone is in vibration mode or silent mode or normal mode (See this).. But vibration mode doesn't mean phone is vibrating right now..

2
  • I believe he didn't mean if the device has that capability. He wants to subscribe to vibration event.
    – Tarik
    Sep 7, 2012 at 3:43
  • Sorry, I just want to know whether vibrator is working, or just not working.
    – AmyWuGo
    Sep 7, 2012 at 3:43
0

getVibrateSetting(int vibrateType) BUT: This method is deprecated. Applications should maintain their own vibrate policy based on current ringer mode that can be queried via getRingerMode().

2
  • I don't want to know the OS setting or the OS status.
    – AmyWuGo
    Sep 7, 2012 at 3:44
  • Your question states: "Could I get the status from the OS service?" and your comment states: "I don't want to know the OS setting or the OS status." Make up my mind what you want friend.
    – gh.
    Sep 7, 2012 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.