使用安卓设备震动器
@SuppressLint("MissingPermission")
public static Vibrator startVibrator(Activity activity) {// 定义震动器
Vibrator vibrator = (Vibrator) activity.getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(new long[]{500, 200, 100, 500,100, 200}, -1);
return vibrator;
}
Activity中使用:
DeviceUtils.startVibrator(this);
注意添加权限:
<!--震动权限-->
<uses-permission android:name="android.permission.VIBRATE"/>