I want to create an Android on click function that will make the phone vibrate for 5 sec.
答案 0 :(得分:2)
Try this out:
Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(5000); // 5000 miliseconds = 5 seconds
And add the permision in AndroidManifest.xml
<uses-permission android:name="android.permission.VIBRATE"/>
Read more here please, this is the duplicate and easily to be found: How to make an Android devide vibrate