Android apps have no sound

No notification sound when sending notification from firebase in android

I am sending push notification from firebase to my Android Application. but when my app is in background firebase onMessageReceived method is not called instead firebase send notification to system for showing notification in system tray. notification appears in system tray but no sound for notification even i have allowed notification sound for my app in system settings.

what I can do to play notification sound when notification received from firebase.

This is how I am sending notification from firebase to my app Blogpost link.

10 Answers 10

In the notification payload of the notification there is a sound key.

From the official documentation its use is:

Indicates a sound to play when the device receives a notification. Supports default or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/.

If you want to use default sound of the device, you should use: «sound»: «default» .

For those who don’t know firebase handles notifications differently when the app is in background. In this case the onMessageReceived function is not called.

When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the app launcher by default. This includes messages that contain both notification and data payload. In these cases, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.

@note for custom notification sound:-> «sound» : «MyCustomeSound.wav»

select advanced options when Write a message, and choose sound activated

this is My solution

The onMessageReceived method is fired only when app is in foreground or the notification payload only contains the data type.

For downstream messaging, FCM provides two types of payload: notification and data.

For notification type, FCM automatically displays the message to end-user devices on behalf of the client app. Notifications have a predefined set of user-visible keys.
For data type, client app is responsible for processing data messages. Data messages have only custom key-value pairs.

Use notifications when you want FCM to handle displaying a notification on your client app’s behalf. Use data messages when you want your app to handle the display or process the messages on your Android client app, or if you want to send messages to iOS devices when there is a direct FCM connection.

Further down the docs

App behaviour when receiving messages that include both notification and data payloads depends on whether the app is in the background or the foreground—essentially, whether or not it is active at the time of receipt.
When in the background, apps receive the notification payload in the notification tray, and only handle the data payload when the user taps on the notification.
When in the foreground, your app receives a message object with both payloads available.

If you are using the firebase console to send notifications, the payload will always contain the notification type. You have to use the Firebase API to send the notification with only the data type in the notification payload. That way your app is always notified when a new notification is received and the app can handle the notification payload.

If you want to play notification sound when app is in background using the conventional method, you need to add the sound parameter to the notification payload.

Источник

How to Fix Android Messages Having No Notification Sound

This guide is specifically for Google’s “Messages” app ( com.google.android.apps.messaging ) – this is the default / stock messages app that comes with many new Android phones, including the newest Pixel 4A model. However, some of the advice about generic notifications settings is applicable to all apps and Android in general. Especially for apps that have their own notification controls.

The Issue

The problem is pretty straightforward.

Читайте также:  Death rally для андроида

After getting a brand new phone (Pixel 4a, with Android 10), incoming text messages / SMS no longer triggered an audible notification sound. Even after tweaking global notifications settings and setting ringer volume to maximum, no text messages could trigger an audio alert. There would be a visual notification shown, but no sound.

Searching across the internet, it is clear this is not an isolated incident. At first, I was going to blame myself, but when the same exact thing happened to some one else I knew, I realized there is a clear issue at hand.

The Fix

After tweaking every setting I could find related to notifications, I finally found the solution in a menu buried several layers deep. Turns out that Messages has its own notifications settings that override global settings, and for some reason, the notification sound was set to none! Setting it to any other sound option fixed it.

There are a few ways to get to this buried setting.

  1. Open the “Messages” App
  2. Tap the three dots in the upper right to open the menu, then select Settings
  3. Tap the Notifications menu option
  4. Tap the Incoming messages menu option
  5. Make sure the setting on this page is set to “Alerting” and not “Silent”. Now look towards the bottom of the screen and tap the Advanced label to expand the advanced sub menu
  6. In advanced sub menu, look for the Sound option. If it is set to None , then this is definitely your issue!
  7. Tap the Sound option and select one of your ringtones / notification; this will be the sound that plays when you get a new message. Make sure to hit save!
  8. You are done! Try to test it by having someone send you a text message. Or use a site like this one to test it.

Alternatively, you can get to the setting by starting a slightly different way:

  1. Long press the “Messages” app icon in your app drawer or home screen, and tap the App Info option or icon
  2. Tap the Notifications option
  3. You can now start on step 4 of the above section.

If you want to see these steps in action, below is a screen recording I made:

You can also find the video above here.

The Culprit / Theories

Since I observed this issue happening to two different users who were both switching to new phones (with Android 10), my guess is that it has to do with Google’s protocol for device migration and setting sync (related: backup overview). My theory is something like this:

  1. User is on an older version of Android. They have their messaging app notifications set to either default notification sound , a system specific sound, or a custom sound
  2. User gets a brand new Android phone and / or upgrades to Android 10+
  3. The Android setup process tries to transfer the old setting, but the previous setting is not an option on the new phone. This could be because the ringtone file did not get transferred over, the previous user used a system level notification sound which was deprecated in Android 10, or some other reason.
  4. Rather than default to a specific notification sound, the system defaults to null / None .

If I could talk to a Google engineer, I would point out that this feels like a UX process that could be improved. I would argue that the majority of users probably want some sound set as the default, even if they can’t keep their old setting.

Further troubleshooting

If the above fix did not solve your issue, here are some further things you can try (in combination with making sure the above has been tried):

  • Make sure there is a default notification sound set:
    • Search: “default notification sound”
    • Path: Settings -> Apps & Notifications -> Notifications -> Advanced -> Default notification sound
  • Make sure “Do Not Disturb” mode (aka DND) is OFF
    • Search “do not disturb” OR “dnd”
    • Path: Settings -> Sound -> Do Not Disturb
    • You can also toggle DND through the Android pull down shade, and depending on your settings, you might also have DND configured to turn on automatically based on schedule and/or other triggers
    • If it is ON, you should see a persistent icon in the status bar that looks something like this:
  • Make sure your Ring volume is not set to zero / vibrate only
    • It used to be that “ringtone” volume was separate from “notifications” volume, but starting with Android 10 (?), these have been combined into one setting: “Ring volume”. If it is set to zero or vibrate only, then no notifications will emit sound (unless there is an app-specific override?)
      • If it is set to vibrate only, you should see this icon in your status bar:
      • If it is set to zero and vibrate is off, you should see this icon in your status bar:
    • Warning: Using the physical rocker buttons on your phone to adjust volume no longer adjusts the ring volume (starting with Android Pie?) – it adjusts the Media volume. I agree with those dissenting that this is a silly change for Android to make.
  • Make sure that you don’t have individual per-contact / conversation notifications set to silent
    • See below section
Читайте также:  Андроид тест с ответами

Per Contact Messages Notification Settings

Android actually lets you set the messaging notifications setting as granular as per-contact / conversation. So, for example, contact “Joshua” that texts you too many jokes that don’t need immediate attention can be set to “silent”, whereas “Boss” is set to “priority”, since you never want to miss a text from them.

Unfortunately, this is also a way that your notifications settings can get screwed up. There are a few ways to check for this, and remedy it.

If you want to check to see if any contacts have a customized messaging notification setting, navigate to Settings -> Apps & Notifications -> Conversations :

  • This screen shows you any text conversations / contacts that have a special non-default notification setting applied (or if you even opened up that panel in the past)
  • There seems to be a glitch with this settings page, at least on my device:
    • All entries show as Default settings within the list, even if they are actually set to Silent or something else, which does show up if you click through to change the setting

To fix this, and restore contacts to the default setting, you can:

  • Use the above route ( Settings -> Apps & Notifications -> Conversations ) and change each entry in the list to Default
  • Within individual messaging conversations within the Messages app, you can access the notification setting for that conversation by clicking the three dots in the upper right, then Details , and finally Notifications
  • Bulk: In my research, the only bulk approach that I came across was by clearing the data for the messaging app. According to multiple comments, this will reset all the per-conversation notification settings, but not delete any messages.
    • I am slightly reluctant to recommend this, as it is something I have never tried. If you were to try this, I would strongly recommend backing up all your messages first (like in this guide).

Video Overview

This video does an excellent job of covering an exhaustive list of reasons why incoming messages might not be triggering audio alerts:

Источник

Android Phone Speaker Fixes

I can’t hear anything on my Android phone

There’s nothing more annoying than when you’re talking hands-free and your phone speaker goes mute. If the speaker is not working on your Android device, there are a dozen troubleshooting techniques you can try to restore the volume.

Instructions in this article apply broadly to all smartphones and tablets running the Android OS.

How to Fix It When the Speaker Is Not Working on Your Android Device

Follow these steps to uncover the cause of the problem:

Turn on the speaker. If you can’t hear anyone on the other end during a call, check to see if the speaker is enabled. If it is activated, the speaker icon is green or highlighted. If it’s not, tap the speaker icon so that it lights up to enable it.

You can hear through the earpiece even if the speaker is disabled.

Читайте также:  Что такое dump android

Turn up the in-call volume. If the speaker is enabled, the volume may be turned down too low. Press the volume up button on your phone. This tends to be on the left side of most phones. Press this button to display the volume level indicator. To increase the volume, press the button or slide the volume indicator to the right until you hear the other person speaking.

The only way to test and set the in-call volume is to be in a call. Make a test call to your voicemail to experiment with the in-call settings.

Adjust the app sound settings. Some apps, such as Facebook, allow you to mute the sound separately from the main volume control. If you don’t hear sound in one particular application, check the app’s sound settings. You might have the sound muted or turned down low in the app.

Check the media volume. If you still don’t hear anything, verify that the media volume isn’t turned down or off:

  1. Navigate to Settings.
  2. Tap Sounds and vibration.
  3. Tap Volume.
  4. Move the Media slider to the right to increase volume.

Alternatively, press the volume up or volume down buttons on your device, then tap the down arrow in the upper-right corner of the screen to reveal the sound mixer settings.

Make sure Do Not Disturb isn’t enabled. This handy feature could be the culprit for no sound. To disable this setting, navigate to Settings and turn off the Do not disturb toggle.

Android 6.0 (Marshmallow) displays the following options: Total silence, Alarms only, and Priority only.

Make sure your headphones aren’t plugged in. Most Android phones automatically disable the external speaker when headphones are plugged in. This could also be the case if your headphones aren’t completely seated in the audio jack.

Remove your phone from its case. Some phone holsters or cases may muffle the sound. Remove your Android phone from its case, then test the sound. You’ll notice immediately if the sound improves.

Reboot your device. A reboot often clears up any software glitches that may disable the sound. Press and hold the power button until you see a set of options on the screen. Tap Restart to reboot your phone.

Turn off your device and turn it back on. If rebooting doesn’t do the trick, your phone may have some technical issue that requires you to turn it off and on. Press and hold the power button, and then tap Power off. Once you power your phone back on, test the sound with an app.

Reinsert the battery. Not all phone models have removable batteries, but if yours does, remove and reinsert the battery to completely reset the phone without wiping your data. Consult the cellphone manufacturer’s manual or website for details.

Clean the speaker. Speakers get dirty or clogged, so a bit of cleaning could make sounds clear again. Before you clean the speaker, turn off the phone and remove the battery. Use a can of compressed air to blow quick bursts into the speaker. You’ll see some lint and other debris after blowing it out. You may be able to blow through the speaker without opening the case.

Consult your phone’s manual or a smartphone dealer for help with this process. Do not attempt to clean the speaker if you aren’t familiar with smartphone hardware, or if your device is under warranty.

Reset all settings. Before you take your phone back to the store, reset the phone to its default state. When you reset your phone’s settings to the default, any app or software setting that may have disabled the speaker is eliminated.

Check your device’s manual. If the above tricks don’t work, consult your device’s documentation or the manufacturer’s website for more specific guidance.

Still having trouble? It might be time to throw down some dollars for a new Android. We’ve tested a lot of them; take a look at our recommendations to see what might work for you and your budget.

Источник

Оцените статью