Mohamed Hafez
Mohamed Hafez

Reputation: 8691

How to Vibrate the system default pattern in Android?

I know about the Vibrate class and how to use it, but where can I get the system default vibration pattern to use? Or is there some kind of intent I can launch to get the system to vibrate its default vibration?

Upvotes: 10

Views: 3371

Answers (2)

mhsmith
mhsmith

Reputation: 8091

See View.performHapticFeedback.

Upvotes: 2

Jorgesys
Jorgesys

Reputation: 126495

Create a method that reproduce the default vibration and call it on every selection.

import android.os.Vibrator;

private void vibrate(){
        Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        v.vibrate(1000);
    }

permission required in AndroidManifest.xml file:

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

Upvotes: 7

Related Questions