【问题标题】:notification dynamic large icon not working android通知动态大图标不起作用android
【发布时间】:2016-03-31 03:07:24
【问题描述】:

我想在通知区域显示动态图标(通过传递文本生成)!

设置小图标 mathod 使用已经存在的可绘制包图标,所以我不能使用它。

set large icon 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 它会显示通知。

【问题讨论】:

    标签: android bitmap notifications


    【解决方案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);    `
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多