android如何从左上角的屏幕中删除通知小图标

时间:2015-11-02 13:49:22

标签: android icons android-notifications

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

        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);

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

1 个答案:

答案 0 :(得分:-1)

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

.setSmallIcon(android.R.color.transparent)