Android Notification Sound
What was missing from my previous code:
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(alarmSound);
Different notification sound not working in Oreo
Problem:
It seems Notification Channel issue.
Solution:
Either you should create separate channel, or you should delete your own channel.
Strategy:
1) Create separate channel:
You may select this strategy if you want to persist multiple channels along with various configuration for your app.
To create separate channel, just provide unique channel ID while creating it.
i.e.:
NotificationChannel channel = new NotificationChannel(uniqueChannelId, name, importance);
2) Delete your existing channel and re-create it:
You may select this strategy if you want to persist only one channel along with updated configuration for your app.
To delete your own channel and re-create it, following may work fine:
NotificationManager mNotificationManager = getSystemService(NotificationManager.class);
NotificationChannel existingChannel = notificationManager.getNotificationChannel(channelId);
//it will delete existing channel if it exists
if (existingChannel != null) {
mNotificationManager.deleteNotificationChannel(notificationChannel);
}
//then your code to create channel
NotificationChannel channel = new NotificationChannel(channelId, name, importance);
Related Topics
How to Downgrade My Sdk Version
Sending Text Messages Programmatically in Android
Enable/Disable Zoom in Android Webview
Get the Current Fragment Object
Using Android Vector Drawables on Pre Lollipop Crash
Mediacodec and Camera: Colorspaces Don't Match
Why Is Android Studio Reporting "Uri Is Not Registered"
Adb Root Is Not Working on Emulator (Cannot Run as Root in Production Builds)
How to Pause/Resume Thread in Android
Defaulthttpclient to Androidhttpclient
How to Do a Http Post in Android
Execution Failed for Task ':App:Compiledebugaidl': Aidl Is Missing
Version Conflict Updating to Play-Services 9.4.0 Android Studio 2.2