Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 887
zola Avatar asked Jun 14 '16 07:06

zola


People also ask

How do you get a vibration pattern on your phone?

Tap on the “More option > Vibration pattern,” and it will be set to default. When you tap on this option, your Android device will open to the stock vibration patterns it has. You can choose from patterns such as default, basic call, heartbeat, ticktock, waltz, and zig-zig-zig.

Can I change the vibration pattern on Android?

Tap any app to bring up a list of your currently installed apps. Tap each app on this list that you want to set up a custom notification vibration pattern for, then press the Pick Apps button at the bottom. Press contains anything for an overview of the options you can choose for the custom notification.

What is vibration pattern?

Android Vibration Vibration Patterns You can create vibration patterns by passing in an array of longs, each of which represents a duration in milliseconds. The first number is start time delay. Each array entry then alternates between vibrate, sleep, vibrate, sleep, etc.

How do I change the vibration pattern on my Samsung?

To find this, swipe down from the top of the screen to open the Quick settings panel, and then tap the Settings icon. Tap Sounds and vibration, and then select Vibrate. Then, customize the options for Call vibration pattern, Notification vibration pattern, and Vibration intensity.


Video Answer


2 Answers

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.

like image 68
alijandro Avatar answered Oct 17 '22 13:10

alijandro


As far as I know the default vibrate pattern is a

{ delay, vibrate, sleep, vibrate, sleep } pattern

In case of your code

long[] pattern = new long[] { 1000, 1000, 1000, 1000, 1000 };

The vibration now set to a delay of 1000 ms. If you set the first one to 0, it will go off instantly.

like image 3
Godslave Avatar answered Oct 17 '22 13:10

Godslave