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.
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.
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.
Per the comments on this Google+ post:
those [warnings] are currently expected when using
NotificationCompat
on Android O devices (NotificationCompat
always callssetSound()
even if you never pass in custom sound).until the Support Library changes their code to use the
AudioAttributes
version ofsetSound
, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With