title: How to vibrate Android device on button click using vibrator effects using Kotlin?
body: <p>How to vibrate an Android device coding with Kotlin when pressing any buttons? I have used this code below, but there aren't any effects or vibrations performed.</p>
  <pre><code>//click listener
      imgNextBtn.setOnClickListener {
          val vibe:Vibrator = activity?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
          vibe.vibrate(500)
          Utilities.alertDialog(this,
                  activity!!,
                  mContent!!
      }
  }
  </code></pre>
  <p>Or</p>
  <pre><code> //click listener
      imgNextBtn.setOnClickListener {
          val vibe:Vibrator = activity?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
          var effect:VibrationEffect = VibrationEffect.createOneShot(1000, VibrationEffect.DEFAULT_AMPLITUDE);
  
      vibe.vibrate(effect)
          
          Utilities.alertDialog(this,
                  activity!!,
                  mContent!!
      }
  }
  </code></pre>
  <p>Android Manifest:</p>
  <pre><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  package=&quot;com.china.openkey&quot;&gt;
  
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot; /&gt;
  </code></pre>