Ich verwende das folgende Snippet, um Benachrichtigungen in meiner Android App zu generieren.android 7.0 Benachrichtigungssymbol erscheint weißes Quadrat
private void sendNotification(String contentText, String message) {
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.putExtra("clear","clear");
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent piResult = PendingIntent.getActivity(this, 0, resultIntent,0);
NotificationCompat.Builder builder=new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setColor(ContextCompat.getColor(getApplicationContext(),R.color.red))
.setContentTitle("title")
.setContentText(message)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(getResources()
,R.drawable.notification))
.setContentIntent(piResult);
NotificationCompat.InboxStyle notification = new NotificationCompat.InboxStyle(builder);
int i;
for(i=0; i<messageList.size();i++){
notification.addLine(messageList.get(i));
}
notification.setBigContentTitle("title");
notification.setSummaryText(contentText);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID,notification.build());
}
Es funktioniert in android 5 und 6, aber für Android Nougat ist es nicht
Das Bild ist nur transparent –
@SureshKumar Ihr Bild hat wahrscheinlich einen transparenten Hintergrund, aber das Symbol ist ein Quadrat, so dass Sie ein quadratisches weißes Bild erhalten. Ihr gesamtes Bild mit Ausnahme der transparenten Teile wird in Weiß konvertiert. –
@ AlbertoMéndez Danke, ich werde das überprüfen –