简体   繁体   English

API级别26上的通知图标

[英]Notification icon on API Level 26

I don't understand which icon android api 26 use for push notification when app is close. 我不明白当应用关闭时,android api 26使用哪个图标进行推送通知。 When I receive push notification it's always default icon with droid. 当我收到推送通知时,它始终是带有droid的默认图标。

I remove all default icon from ressources, set android:roundIcon="@drawable/ic_launcher" (ic_launcher is a png) 我从资源中删除了所有默认图标,设置android:roundIcon="@drawable/ic_launcher" (ic_launcher是png)

Edit : My issue is when this is the system tray display the notification https://firebase.google.com/docs/cloud-messaging/android/receive 编辑:我的问题是,这是在系统托盘上显示通知https://firebase.google.com/docs/cloud-messaging/android/receive

The icon which you have set in notification object is display 显示在通知对象中设置的图标

notification.setSmallIcon(R.drawable.icon);

For Example 例如

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Intent resultIntent = new Intent(getApplicationContext(), MainActivity.class);
    resultIntent.putExtras(bundle);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
    Notification notification;
    Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notificationsound);
 notification = new Notification.Builder(this)
                .setSmallIcon(R.drawable.lg_logo)
                .setContentTitle(title)
                .setStyle(new Notification.BigTextStyle().bigText(msg))
                .setAutoCancel(true)
                .setContentText(msg)
                .setContentIntent(contentIntent)
                .setSound(sound)
                .build();
    notificationManager.notify(0, notification);

user notification.setSmallIcon(R.drawable.icon); 用户notification.setSmallIcon(R.drawable.icon); to set the small icon also when using an image don't make it larger than 250px X 250px. 在使用图片时也要设置小图标,但不要使其大于250px X 250px。

Put below code in You Manifest.xml 将以下代码放在You Manifest.xml

           <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_notification" />
           <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorAccent" />

Also, Make sure icon you have generated is as per the guidelines provided by Google. 另外,请确保您生成的图标符合Google提供的准则。 Here is official guidelines 这是官方指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM