我想在通知区域显示动态图标(通过传递文本生成)!
设置小图标mathod使用已经存在的可绘制包图标,所以我无法使用它。
设置大图标mathod使用位图图像所以我生成位图图像并将其传递给setlargeicon mathod这里是我的代码
Bitmap b1 = drawText(String.valueOf(level),24,24);
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this)
.setLargeIcon(b1)
.setTicker("better level "+level);
Intent intent1 = new Intent( context1, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context1, 786 , intent1, 0);
builder.setContentIntent(pIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = builder.build();
notif.flags=Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(786, notif);
我没有收到任何通知..如果我使用带有ic_launcher图像的set small icon mathod它会显示通知。
答案 0 :(得分:1)
您始终需要设置一个小图标。
Bitmap b1 = drawText(String.valueOf(level),24,24);
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this)
.setSmallIcon(R.drawable.someIcon)
.setLargeIcon(b1)
.setTicker("better level "+level); `