Reduce the vibration intensity of the notification to zero in android

In my application, I want to turn off vibration when a notification arrives. I can mute the notification sound, but could not stop the vibration.

To mute the notification sound, I used the following code:

 if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != value) {
        audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, value, 0);
        Utils.log("Volume Changed to " + value);
    }

Please suggest how to change the vibration intensity of notifications to zero or suggest another way to cancel vibration when a notification arrives.

audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION,
        AudioManager.VIBRATE_SETTING_OFF);

setVibrateSetting not working and deprecated

I can manually change the vibration intensity of the notification on Samsung devices:

  • Go to setup
  • Click the My Devices tab.
  • Click Sound and open Vibration Intensity.
  • Select vibration intensity for incoming call, notification and feedback.

But how can I do this programmatically? please, help.

+4
2

- . Android .

0

, . , /, , .

- (PWM) (, .) : T (, 1 ) 900 (tv1) 100 (ts1) - . 800 (tv2) 200 (ts2) - .., 0.

PWM vibration control

Android- Vibrator .

@Rohit J, ( ) , :

long[] pattern = {
        0,     // start vibrate immediately
        900,   // vibrate 1 900 ms
        100,   // silence 1 100 ms
        800,   // vibrate 2 800 ms
        200,   // silence 2 200 ms
        700,
        300,
        600,
        400,
        500,
        500,
        400,
        600,
        300,
        700,
        200,
        800,
        100,
        900,
};

Notification:

Notification.Builder builder = new Notification.Builder(context);
builder.setContentIntent(contentIntent)
        ...
        .setVibrate(pattern)
        ...;

NB! , ( ) (, , , , - ).

+2

Source: https://habr.com/ru/post/1661269/


All Articles