Vibrate Android Phone Programmatically

android-logoVibrating your Android phone programmatically is very easy. The code is common for all Android devices which has vibrator hardware. You can vibrate your Android device  using different pattern until you cancel the vibrator either by the Android OS or manually by your Android app. You can also download the complete source code from this post.

Note: You can vibrate your phone like below patterns.

1. Vibrate for a given period (Time in milliseconds).

2. Vibrate in a given pattern.



Lets start cording for vibrating your phone programmatically.

STEP 1: Add below permission in your Android manifest file.

Note: If you forget to add the below line in your manifest file, then you will get force-close message while running the application in the device.

 STEP 2: Get running instance of the Vibrator Service

Get the running instance of the Android Vibrator service. Please don’t create a new instance of Vibrator class. So we will get the running instance using the function getSystemService() in our jave file as below.

Note:  Now we have the running instance, so we can vibrate the phone as per our requirement.

1. Vibrate for a given period (Time in milliseconds).

After getting the instance as above step-2, just add the below line to vibrate the phone for a given time period.

2. Vibrate in a given pattern.

This is the method which is used by most of the Android apps. Pattern mean you can set a pattern like start/stop vibration in a  regular interval like below.

3. Cancel Vibration

just call cancel() API to cancel the vibration, which has already started.

downloadDownload complete source code for Vibrate Android Phone Programmatically from here.

I hope this small tutorial will help you at it’s best.


Post By SmrutiRanjan (57 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon


6 Responses to Vibrate Android Phone Programmatically

  1. karim says:

    Oh, very nice job.
    Learning is a pleasure with such things.

  2. jason says:

    nice example,
    I want to make an application through which we can make profiles for vibrator. Reason behind it is that my phone starts vibrating if any SMS arrives even when i am calling someone when i am holding it near my ears. So i want to stop vibrator at calling time and lateron get back to normal vibrating mode. Help me making this app.

  3. soumya ranjan sahu says:

    awesome sir..realy great tutorial for beginners..plz keep this always…it will help for us

  4. rhoadster91 says:

    I have the following code:

    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    And declared the permission in Manifest.

    The vibration works properly on my Nexus 4 and Samsung Galaxy Ace but does not seem to work on ANY Xperia phone.
    Do you know the solution??

  5. yoonus says:

    you are a great person
    i got many usful things fromu thankz ur contact number ?

  6. home business ideas says:

    obviously like your web-site but you have to test the
    spelling on quite a few of your posts. Many of them are rife with spelling issues
    and I to find it very bothersome to tell the reality
    nevertheless I will certainly come again again.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × five =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">