手机震动

    技术2025-01-14  10

    import android.os.Vibrator;

     

     

    private Vibrator mVibrator;

     

    mVibrator = (Vibrator)getApplication().getSystemService(

    Service.VIBRATOR_SERVICE);

     

     

     

    mVibrator

    .vibrate(new long[] { 100, 10, 100, 1000 }, -1);

     

    mVibrator

    .vibrate(new long[] { 100, 100, 100, 1000 }, 0);

     

    mVibrator.vibrate(new long[] { 1000, 50, 1000, 50,

    10000 }, 0);

     

    -1表示不重复震动

     

     

     

    AndroidManifest.xml追加权限

    <uses-permission android:name="android.permission.VIBRATE"></uses-permission>

    最新回复(0)