Getting Started with Vibration
suggest changeGrant Vibration Permission
Before you implement the vibration code, add this permission to the Android manifest:
<uses-permission android:name="android.permission.VIBRATE"/>
Import Vibration Library
import android.os.Vibrator;
Get instance of Vibrator from Context
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
Check that the device has a vibrator
vibrator is the instance from the previous step.
boolean isHaveVibrate() {
return vibrator != null && vibrator.hasVibrator();
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents