我已使用此代码
private void sendNotification() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
int randomNumber = (int) System.currentTimeMillis();
PendingIntent pendingIntent = PendingIntent.getActivity(this, randomNumber, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.BigPictureStyle nbs = new android.support.v7.app.NotificationCompat.BigPictureStyle();
nbs.setSummaryText("Big Message").bigPicture(BitmapFactory.decodeResource(getResources(),R.drawable.general_push)).setBigContentTitle("Big Title");
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("Small Title")
.setStyle(nbs)
.setContentText("Small Message")
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder.setSmallIcon(R.drawable.notif_trans);
}else{
notificationBuilder.setSmallIcon(R.drawable.notif_logo);
}
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(randomNumber, notificationBuilder.build());
}
在我的棒棒糖设备中,我测试的图标即将出现,但它只是白色,有人告诉必须添加setColorFilter我不知道如何设置为app图标,我直接设置了带有可绘制ID的smallIcon,我必须设置setColorFilter?请帮我。有些人提供了这段代码
if (entry.targetSdk >= Build.VERSION_CODES.LOLLIPOP) {
entry.icon.setColorFilter(mContext.getResources().getColor(android.R.color.white));
} else {
entry.icon.setColorFilter(null);
},
这是什么是entry.icon我们将如何获得以及如何将其设置为小图标
答案 0 :(得分:0)
见以下链接:
Notification bar icon turns white in Android 5 Lollipop
你必须制作只有白色的图标,并在Android版本为棒棒糖及以上时设置该图标。