0

I'm using NotificationCompat.Builder to build notification, which based on app configuration can make sound or vibrate or both. All works fine BUT when phone is switched to vibrate mode then the notifications vibrate even when they have only sound enabled. Why does builder.setSound result in vibration when phone is switched to vibrate mode? Is there a way to get rid of that?

I found similar SO question but it does not seem to resolve my problem.

here are few versions, tested on Samsung Galaxy Note 3

compileSdkVersion 23
minSdkVersion 14
targetSdkVersion 23
Tono Wiedermann
  • 608
  • 6
  • 13

1 Answers1

1

Why does builder.setSound result in vibration when phone is switched to vibrate mode?

Because that's what vibrate mode does. It replaces ringtones and other notification sounds with a vibration pattern, so the user knows that there was a notification, but the alert is (usually) inaudible.

Is there a way to get rid of that?

You are welcome to not call setSound() when the user has vibration mode on.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • thanks! I was hoping there will be better way but I get your point about the purpose of vibration mode – Tono Wiedermann Nov 23 '15 at 16:48
  • @TonoWiedermann: Basically, Android isn't set up for you, at the app level, to be specifying whether or not to play ringtones or do vibrations. There's nothing stopping you from doing that, but it requires more fussing, detecting whether or not vibration is on and so forth. Android thinks that sound-versus-vibrate is a system-wide thing and optimizes for that. – CommonsWare Nov 23 '15 at 16:49