Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notifications fail to display in Android Oreo (API 26)

I get this message when trying to display a notification on Android O.

Use of stream types is deprecated for operations other than volume control

The notification is straight from the example docs, and displays fine on Android 25.

like image 428
Sky Kelsey Avatar asked Jul 30 '17 02:07

Sky Kelsey


People also ask

What is notification in mad?

A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app. Users can tap the notification to open your app or take an action directly from the notification.

What is NotificationCompat builder?

public class NotificationCompat.Builder. Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts. On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.


1 Answers

Per the comments on this Google+ post:

those [warnings] are currently expected when using NotificationCompat on Android O devices (NotificationCompat always calls setSound() even if you never pass in custom sound).

until the Support Library changes their code to use the AudioAttributes version of setSound, you'll always get that warning.

Therefore there's nothing that you can do about this warning. As per the notification channels guide, Android O deprecates setting a sound on an individual notification at all, instead having you set the sound on a notification channel used by all notifications of a particular type.

like image 110
ianhanniballake Avatar answered Sep 21 '22 20:09

ianhanniballake