Disable vibration for a notification

前端 未结 7 1149
北荒
北荒 2020-12-09 15:11

I\'m writing an app using notification. Google developer guidelines encourages developers to provide settings to customize the notifications (disable vibration, set notifica

相关标签:
7条回答
  • 2020-12-09 16:05
    private void removeSoundAndVibration(Notification notification) {
            notification.sound = null;
            notification.vibrate = null;
            notification.defaults &= ~DEFAULT_SOUND;
            notification.defaults &= ~DEFAULT_VIBRATE;
    

    This code is from Notification Compat Api Class. This should work, add all these to your builder.

    0 讨论(0)
提交回复
热议问题