How to make an Android device vibrate?

后端 未结 13 1728
长发绾君心
长发绾君心 2020-11-22 15:47

I wrote an Android application. Now, I want to make the device vibrate when a certain action occurs. How can I do this?

相关标签:
13条回答
  • 2020-11-22 16:35

    You can Vibrate the Device and its work

       Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
               v.vibrate(100);
    

    Permission is necessary but not on runtime permission required

    <uses-permission android:name="android.permission.VIBRATE"/>
    
    0 讨论(0)
提交回复
热议问题