推送通知图标Android

推送通知图标Android,android,notifications,push-notification,android-notifications,Android,Notifications,Push Notification,Android Notifications,如何在android的通知区添加通知图标? 我尝试了这个,但这在通知区域显示了一个空白 mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, ne

如何在android的通知区添加通知图标? 我尝试了这个,但这在通知区域显示了一个空白

mNotificationManager = (NotificationManager) this
                .getSystemService(Context.NOTIFICATION_SERVICE);        
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, Receive_Message_list.class), 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this)           
        .setSmallIcon(R.drawable.pushicon)
        .setContentTitle("MAY-I")
        .setStyle(new NotificationCompat.BigTextStyle()
                .bigText(notification_message))
                .setContentText(notification_message);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());

在安卓5.0上,图标通过一个颜色过滤器,使所有不透明像素变为白色

使用颜色将您的应用程序与其他应用程序区分开来。通知图标应仅为透明背景图像上的白色


在安卓5.0上,图标通过一个颜色过滤器,使所有不透明像素变为白色

使用颜色将您的应用程序与其他应用程序区分开来。通知图标应仅为透明背景图像上的白色


你能分享一下通知的截图吗。。代码似乎很好。。logcat中也有错误吗?logcat没有显示任何错误。但状态栏显示一个空白的白色图标代替应用程序icon@RahilAli . 你能开始接受问题的答案吗?你能分享通知的截图吗。。代码似乎很好。。logcat中也有错误吗?logcat没有显示任何错误。但状态栏显示一个空白的白色图标代替应用程序icon@RahilAli . 你能开始接受问题的答案吗?是的,这是正确的,每个人都想知道为什么实际通知中有一个彩色图标,而它在顶部的实际状态栏中只显示一个白色轮廓。是的,这是正确的,每个人都想知道为什么实际通知中有一个彩色图标,而它在顶部的实际状态栏中仅显示白色轮廓。
private void showNotification(final String title, String text, int ID, boolean showTimeStamp) {

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) //Use a builder
                .setContentTitle(title) // Title
                .setContentText(text) // Message to display
                .setTicker(text).setSmallIcon(R.drawable.ic_notif_small) // This one is also displayed in ticker message
                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bulb)); // In notification bar

        Intent resultIntent = new Intent(this, MainActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(MainActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);

        //mBuilder.addAction(R.drawable.bulb_small, "OK", resultPendingIntent);

        Notification notification = mBuilder.build();
        notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS | Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;

        long time = 0;
        if (showTimeStamp)
            Calendar.getInstance().getTimeInMillis();
        else
            time = android.os.Build.VERSION.SDK_INT >= 9 ? -Long.MAX_VALUE : Long.MAX_VALUE;

        notification.when = time;

        //notification.icon = R.drawable.ic_moneta_logo_small;

        //mNotificationManager.cancelAll(); //Clear all currently display notifications
        mNotificationManager.cancel(ID);
        mNotificationManager.notify(ID, notification);
    }