【问题标题】:android how to remove the notification small icon from top left screenandroid如何从左上角屏幕中删除通知小图标
【发布时间】:2016-02-02 10:15:09
【问题描述】:

我有这个构建通知的代码,我需要删除左上角屏幕上的小图标,我需要询问是否有任何方法可以防止在创建通知时显示此图标

        String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager notificationManager = 
            (NotificationManager) getSystemService(ns);

    RemoteViews notificationView = new RemoteViews(getPackageName(),
            R.layout.mynotification);
    Notification.Builder notification = new Notification.Builder(
        getApplicationContext())
.setTicker(tickerText)
    .setSmallIcon(R.drawable.ic_launcher)// here how can i make it null or transparent
.setAutoCancel(true)
    .setContentIntent(mContentIntent)

    .setVibrate(mVibratePattern)
    .setContent(notificationView);


    //the intent that is started when the notification is clicked (works)
    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, 
            notificationIntent, 0);



    //this is the intent that is supposed to be called when the 
    //button is clicked
    Intent switchIntent = new Intent(this, switchButtonListener.class);
    PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, 
            switchIntent,  PendingIntent.FLAG_UPDATE_CURRENT);

    notificationView.setOnClickPendingIntent(R.id.closeOnFlash, 
            pendingSwitchIntent);
    notificationView.setOnClickPendingIntent(R.id.appName, 
            pendingSwitchIntent);
    Notification not = notification.build();
    not.flags=Notification.FLAG_ONGOING_EVENT;

    notificationManager.notify(1, not);

我需要将通知留在状态栏上,但不显示左上角的小图标

【问题讨论】:

  • 你试过删除 setSmallIcon(R.drawable.ic_launcher)
  • 是的,然后整个通知被删除!
  • 我已经在这里回答了,可能对其他人有帮助,谢谢。 stackoverflow.com/a/53795196/5923085

标签: android icons android-notifications


【解决方案1】:

好的,现在我找到了解决方案:O 只需要做这个

.setSmallIcon(android.R.color.transparent)

【讨论】:

  • 这个在收到推送时去掉通知栏的图标
猜你喜欢
  • 2014-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-18
  • 1970-01-01
  • 2015-07-30
  • 1970-01-01
相关资源
最近更新 更多