【Phenomenon】
NotificationManager manager = (NotificationManager) XXXXXXService.this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder( XXXXXXService.this); builder.setContentTitle("XXXX"); builder.setContentText("YYYYY"); builder.setAutoCancel(true); builder.setSmallIcon(R.drawable.ic_launcher);//This is the sentence Notification notification = builder.build(); notification.when = System.currentTimeMillis(); Intent intent = new Intent(getApplicationContext(), YYYYYYYYYActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(XXXXXXXXXXXX, XXXXXX); PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), subtitle.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.contentIntent = pendIntent; manager.notify(subtitle.hashCode(), notification);
The above code presents a notification bar, but when the notification bar is expanded, R.drawable.ic_launcher is a circle and a box on GoogleNexus6 (android5.1), and when the notification bar is closed, it is more like a copper coin shape. Do not customize In the case of RemoteView, there is a plan to make the background of the image resource transparent, but in this case the image resource is not colored when the notification bar is closed.
【analyze】
Guess it's probably because android has transformed the smallicon into black and white in order to match the new theme style. (If you know the specific reason, please leave a message)
[Correction]
Change targetSdkVersion to 20