Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android小通知图标未在5.1中显示(棒棒糖)_Java_Android_Push Notification_Android 5.0 Lollipop_Android Notifications - Fatal编程技术网

Java Android小通知图标未在5.1中显示(棒棒糖)

Java Android小通知图标未在5.1中显示(棒棒糖),java,android,push-notification,android-5.0-lollipop,android-notifications,Java,Android,Push Notification,Android 5.0 Lollipop,Android Notifications,我已经实现了推送通知,它工作正常,但是当我收到通知时,小通知图标在棒棒糖上没有显示,,而大图标显示良好,当我收到通知时,状态栏上有一个方形框在棒棒糖上显示将张贴我的代码,我的小通知图标图像和我的代码,请任何人指导我 public void sendNotification(Context context,String message, String action) { try { int icon = R.drawable.notilogoboss;

我已经实现了推送通知,它工作正常,但是当我收到通知时,小通知图标在棒棒糖上没有显示,,而大图标显示良好,当我收到通知时,状态栏上有一个方形框在棒棒糖上显示将张贴我的代码,我的小通知图标图像和我的代码,请任何人指导我

public void sendNotification(Context context,String message, String action) {
        try {
            int icon = R.drawable.notilogoboss;
            String title = context.getString(R.string.app_name);

            Intent intent = new Intent(context, MainActivity.class);
            intent.putExtra("message", message);
            intent.putExtra("action", action);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_SINGLE_TOP);

            PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);

            Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                    .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.logoboss))
                    .setSmallIcon(icon)
                    .setContentTitle(title)
                    .setWhen(System.currentTimeMillis())
                    .setContentText(message)
                    .setAutoCancel(true)
                    .setSound(defaultSoundUri)
                    .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                    .setContentIntent(pendingIntent);

            NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
            int notId = UUID.randomUUID().hashCode();
            notificationManager.notify(notId, notificationBuilder.build());

        } catch (Exception e) {
        }
    }
[![在此处输入图像描述][1][1]

如Android 5.0中所述,通知下Android开发者网站的行为变化:

通知在白色(或非常浅)背景上绘制黑色文本,以匹配新材质设计小部件。确保所有通知都与新的配色方案相匹配。如果您的通知看起来有误,请修复它们:

使用setColor()在图标图像后面的圆圈中设置强调色。更新或删除涉及颜色的资源。系统忽略动作图标和主通知图标中的所有非alpha通道。您应该假设这些图标仅为alpha。系统以白色绘制通知图标,以深灰色绘制动作图标


.

如安卓5.0中所述,安卓开发者网站在通知下的行为变化:

通知在白色(或非常浅)背景上绘制黑色文本,以匹配新材质设计小部件。确保所有通知都与新的配色方案相匹配。如果您的通知看起来有误,请修复它们:

使用setColor()在图标图像后面的圆圈中设置强调色。更新或删除涉及颜色的资源。系统忽略动作图标和主通知图标中的所有非alpha通道。您应该假设这些图标仅为alpha。系统以白色绘制通知图标,以深灰色绘制动作图标


.

您需要使用平面图标。带透明背景的白色是平面正方形图标正在工作,请帮助我使用40x40图标背景填充仍然我得到白色正方形只有棒棒糖前的默认图标即将出现,但5.0后唯一的问题请帮助我并提供一些帮助完整的代码您需要使用平面图标。带透明背景的白色是平面方形图标正在工作,请帮助我使用40x40图标背景填充仍然我得到白色方形仅棒棒糖前默认图标即将出现,但5.0后仅出现问题,请帮助我并提供一些帮助完整代码