Android GCM通知图标重叠(相同图标的两倍,大小)

Android GCM通知图标重叠(相同图标的两倍,大小),android,google-cloud-messaging,android-notifications,android-notification-bar,Android,Google Cloud Messaging,Android Notifications,Android Notification Bar,我在我的应用程序中使用GCM,在android 4.1和4.4设备中,通知图标似乎没有问题,但在android 5.1中,我可以看到两个图标,一个非常小,一个大小正常。小图标位于右下角,与大图标重叠。您可以在这张图片中看到: 这是我的代码: private void generateNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent

我在我的应用程序中使用GCM,在android 4.1和4.4设备中,通知图标似乎没有问题,但在android 5.1中,我可以看到两个图标,一个非常小,一个大小正常。小图标位于右下角,与大图标重叠。您可以在这张图片中看到:

这是我的代码:

private void generateNotification(String message) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(Constants.COMING_FROM_NOTIFICATION, true);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

        Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        String appName = getResources().getString(R.string.app_name);       

        int width;
        int height;
        if (Util.checkAndroidVersionUpperOrEqualThan(11)){      
            width = getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width); 
            height = getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
        }else{
            width = 64;
            height = 64;
        }

        image = Bitmap.createScaledBitmap(image, width, height, false);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_launcher)
        .setLargeIcon(image)
        .setContentTitle(appName)
        .setContentText(message)
        .setSound(defaultSoundUri)
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setContentIntent(pendingIntent)
        .setAutoCancel(true)
        .setCategory(NotificationCompat.CATEGORY_MESSAGE)
        .setStyle(new NotificationCompat.BigTextStyle().bigText(message));

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(0,notificationBuilder.build());
    }

关于
setSmallIcon()
通知类的android文档说明:

设置小图标资源,该资源将用于在状态栏中表示通知。展开视图的平台模板将在左侧绘制此图标,除非还指定了大图标,在这种情况下,小图标将移动到右侧


这意味着大图标在某种程度上被API忽略了。尝试删除正在检查版本的代码。不确定为什么会出现这种情况。

关于
setSmallIcon()
通知类的android文档说明:

设置小图标资源,该资源将用于在状态栏中表示通知。展开视图的平台模板将在左侧绘制此图标,除非还指定了大图标,在这种情况下,小图标将移动到右侧


这意味着大图标在某种程度上被API忽略了。尝试删除正在检查版本的代码。不知道为什么会出现这种情况。

您设置了两个图标,一个小,一个大
。setSmallIcon(R.drawable.ic_launcher)。setLargeIcon(image)
。它将显示这两个如果我删除大,在4.4图标显示不正确。。。如果我删除小图标,通知栏图标不会在所有android版本中显示,因此我认为这两个图标都是必需的。您设置了两个图标,一个是小图标,一个是大图标
。setSmallIcon(R.drawable.ic_launcher)。setLargeIcon(image)
。它将显示这两个如果我删除大,在4.4图标显示不正确。。。如果我删除小图标,通知栏图标不会在所有android版本中显示,因此我认为这两个图标在我的应用程序中都是强制性的相同问题在我的应用程序中是相同的问题