5 notifications android push-notification parse-platform
我正在制作应用程序是我从中获取数据Parse
并将数据传输到Notification以生成并向用户显示.
但由于某些原因,我无法在棉花糖中显示正确的彩色图标
在其他所有Android版本中,它的工作完全正常,但在Marshmallow中,它令人毛骨悚然的白色图标不是我选择的实际.
这是我的通知代码.
Intent cIntent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
cIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentText(data)
.setContentTitle("Notification from Parse")
.setContentIntent(pendingIntent);
Notification notification = builder.build();
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(100, notification);
Run Code Online (Sandbox Code Playgroud)
请帮助我,或告诉我如何摆脱这个问题.
Vip*_*sri 20
第一:它不是来自Marshmallow,Notification图标从Lollipop本身开始变成WHITE.
结帐http://developer.android.com/design/style/iconography.html您将看到白色样式是Android Lollipop中显示通知的方式.
在Android Lollipop中,Google还建议您使用将显示在(白色)通知图标后面的颜色 - https://developer.android.com/about/versions/android-5.0-changes.html
第二:解决方案是设置LargeIcon
Notification Builder
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(largeIcon)
.setContentText(data)
.setContentTitle("Notification from Parse")
.setContentIntent(pendingIntent);
Run Code Online (Sandbox Code Playgroud)
那么,你的通知看起来像这样:
您还可以使用将颜色设置为通知图标的背景.setColor()
.
归档时间: |
|
查看次数: |
6275 次 |
最近记录: |