Tutorial by Examples

Grant Vibration Permission before you start implement code, you have to add permission in android manifest : <uses-permission android:name="android.permission.VIBRATE"/> Import Vibration Library import android.os.Vibrator; Get instance of Vibrator from Context Vibrator vibr...
using the vibrate(long[] pattern, int repeat) Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Start time delay // Vibrate for 500 milliseconds // Sleep for 1000 milliseconds long[] pattern = {0, 500, 1000}; // 0 meaning is repeat indefinitely vibrator.vib...
You can create vibration patterns by passing in an array of longs, each of which represents a duration in milliseconds. The first number is start time delay. Each array entry then alternates between vibrate, sleep, vibrate, sleep, etc. The following example demonstrates this pattern: vibrate 100...
If you want stop vibrate please call : vibrator.cancel();
using the vibrate(long milliseconds) Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(500);

Page 1 of 1