How to Vibrate the system default pattern in Android?
Asked Answered
A

2

10

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?

Ava answered 23/9, 2013 at 17:24 Comment(3)
Is this for use with a notification, or just in general?Davies
oh i know how to do it for notifications, I'm trying to create a VibratorPreference analagous to RingtonePreference, and i want to 'play' the vibration on each selectionAva
I did just gave a try. Looks like 50 is close to my Acer tab under API 19 where 20 is approx what my Galaxy 5 does, under API 21... I can't find any predefined pattern in the API though.Prase
D
7

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"/>
Discredit answered 14/1, 2014 at 16:26 Comment(4)
but 1000 is not the default value for vibration right ? Is there any way, by which we can get android's default vibration pattern ?Tedmann
I've been testing some different values and I think any value between 20 and 50 ms can make it, depending on what you need. To me 50 ms feels like the buttons on my phone, and 20 ms is more like an item selection inside an app.Unpin
@JuanMiguel Just gave a try. Looks like 50 is close to my Acer tab under API 19 where 20 is approx what my Galaxy 5 does, under API 21... I can't find any predefined pattern in the API though.Prase
I've looked in the latinime (google keyboard) and they have a table for finding the values :(Whilst
I
2

See View.performHapticFeedback.

Inlaw answered 24/8, 2016 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.