Monday, March 7, 2011

Android Using devices How to vibrate the phone for a certain time?

By Magesh Kumar   Posted at  4:59 AM   Android No comments


This code vibrates the phone for 1000 milliseconds. After getting the vibrator service with Context.getSystemService we call Vibrator.vibrate for a given time in milliseconds. 
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// 1. Vibrate for 1000 milliseconds
long milliseconds = 1000;
v.vibrate(milliseconds);

// 2. Vibrate in a Pattern with 500ms on, 500ms off for 5 times
long[] pattern = { 500, 300 };
v.vibrate(pattern, 5);


About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

0 comments:

Back to top ↑
Connect with Us

What they says

© 2013 MaGeSH 2 help. WP Mythemeshop Converted by BloggerTheme9
Blogger templates. Proudly Powered by Blogger.