Android Notification is not showing Colour Icon in Marshmallow

前端 未结 1 722
有刺的猬
有刺的猬 2021-01-03 00:25

I am Making application is which i am getting data fromParse and transfering that data to Notification to generate and show it to user.

But for Some Rea

相关标签:
1条回答
  • 2021-01-03 01:09

    First : Its not from Marshmallow, Notification icon started turning out WHITE from Lollipop itself.

    Checkout http://developer.android.com/design/style/iconography.html you will see that the white style is how notifications are meant to be displayed in Android Lollipop.

    In Android Lollipop, Google also suggests you to use a color that will be displayed behind the (white) notification icon - https://developer.android.com/about/versions/android-5.0-changes.html

    Second : Solution to this is setting LargeIcon to Notification Builder

    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setLargeIcon(largeIcon)
                    .setContentText(data)
                    .setContentTitle("Notification from Parse")
                    .setContentIntent(pendingIntent);
    

    then, your Notification will look something like this :

    You can also set the color to background of Notification Icon by using .setColor().

    0 讨论(0)
提交回复
热议问题