Search code examples
androidandroid-6.0-marshmallowandroid-vibration

how to get the default vibration pattern of an android device?


I am creating an app for Android API 23, and I want to get the default vibration pattern that is used when the phone rings?

I have this so far:

Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {0, 500, 1000}; // default pattern goes here
vibrator.vibrate(pattern, 0);

How can I get the default pattern?


Solution

  • The default vibrate pattern can be found at the following class: com/android/server/notification/NotificationManagerService.java, which is

    static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250};
    

    See the source code from here.

    Unfortunately, there is no public API to get this default pattern so far.