【问题标题】:Android notifications different icon for status bar and notification bodyAndroid通知状态栏和通知正文的不同图标
【发布时间】:2014-03-11 20:56:15
【问题描述】:

我收到了电池电量通知。我想在状态栏和通知中心制作不同的图标。在状态栏中:数字(2 位数字)。在正文中:我的应用程序图标。 我怎样才能做到这一点?应用程序图标也在状态栏中,我该如何更改?

【问题讨论】:

    标签: android push-notification statusbar android-notifications android-notification-bar


    【解决方案1】:

    我不确定你的代码现在是什么样子,但我会做这样的事情:

    Notification.Builder nb = new Notification.Builder(context)
    .setContentTitle("title")
    .setContentText("content")
    .setAutoCancel(true)
    .setLargeIcon(R.drawable.large_icon)
    .setSmallIcon(R.drawable.small_icon)
    .setTicker("ticker text");
    NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(100, nb.build());
    

    注意setLargeIcon()setSmallIcon()。你想在'ticker'中显示的图标应该设置在setSmallIcon(),对于你所谓的'通知中心',你应该使用setLargeIcon()。应该可以的。

    【讨论】:

      猜你喜欢
      • 2014-07-15
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多