$*#@%$ ca-app-pub-4111868940087848/3418151202
To vibrate a phone we need following Permission Do not forget to declare this permission in Manifest.
<uses-permission android:name="android.permission.VIBRATE"/>
We can Vibrate a Phone Using an Activity , Service and Using Threads.
Using Activity will not be a good Idea because it takes time to vibrate the Phone and an Activity always runs in foreground.
We will implement using Service because a Service runs in Background.
for we need to have an Object of Class Vibrator, we do not create the Object directly but we get Vibrate System Service.
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
Add <uses-permission android:name="android.permission.VIBRATE"/> in Your Manifest
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
// pass the number of millseconds fro which you want to vibrate the phone here we
// have passed 2000 so phone will vibrate for 2 seconds.
v.vibrate(2000);
// If you want to vibrate in a pattern
// long pattern[]={0,800,200,1200,300,2000,400,4000};
// 2nd argument is for repetition pass -1 if you do not want to repeat the Vibrate
// v.vibrate(pattern,-1);
To vibrate a phone we need following Permission Do not forget to declare this permission in Manifest.
<uses-permission android:name="android.permission.VIBRATE"/>
We can Vibrate a Phone Using an Activity , Service and Using Threads.
Using Activity will not be a good Idea because it takes time to vibrate the Phone and an Activity always runs in foreground.
We will implement using Service because a Service runs in Background.
for we need to have an Object of Class Vibrator, we do not create the Object directly but we get Vibrate System Service.
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
Add <uses-permission android:name="android.permission.VIBRATE"/> in Your Manifest
Code to Vibrate the Phone
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
// pass the number of millseconds fro which you want to vibrate the phone here we
// have passed 2000 so phone will vibrate for 2 seconds.
v.vibrate(2000);
// If you want to vibrate in a pattern
// long pattern[]={0,800,200,1200,300,2000,400,4000};
// 2nd argument is for repetition pass -1 if you do not want to repeat the Vibrate
// v.vibrate(pattern,-1);
What's up colleagues, nice post and pleasant arguments commented here, I am
ReplyDeletereally enjoying by these.
excellent submit, very informative. I'm wondering why the
ReplyDeleteother experts of this sector don't notice this.
You must proceed your writing. I'm confident, you've a huge
readers' base already!
Good post. I learn something totally new and challenging on blogs I stumbleupon every day.
ReplyDeleteIt's always exciting to read through content from other writers and practice something from other web sites.
Good information.
ReplyDeletebigolive
This very code information.
ReplyDeletebigo live
Great goods from you, man. I've consider your stuff prior to and you're simply too wonderful.
ReplyDeleteI actually like what you have got right here, really like what you are stating and the way during which you are saying it.
You make it enjoyable and you continue to take care of to keep it sensible.
I can not wait to learn much more from you. This is really a tremendous website.
BÀI VIẾT CỦA BANJ THẬT HAY. bẠN CÓ THỂ XEM THÊM DỊCH VỤ SOI CẦU MIỄN PHÍ CHÍNH XÁC 99% TẠI TRANG Hội bàn đề
ReplyDelete