android – Show just small icon in status bar without showing notification-ThrowExceptions

Exception or error:

I want to show constantly small icon in the status bar, without show the notification itself on the notification tray of the system.

I tried using custom layout and set the visibility of the root element to View.GONE, or View.INVISIBLE, but for both, the system ignores it.

I also tried to set the height of the root element but the system ignores this too.

Here is my code:


<LinearLayout xmlns:android=""

And the code for display the Notification:

 NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
 NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx);
 Intent resultIntent = new Intent(ctx, SettingsActivity.class);
 PendingIntent resultPendingIntent = PendingIntent.getActivity(ctx, 0, resultIntent, 0);
 int layout =  R.layout.custom_notification ;
 RemoteViews contentView = new RemoteViews(ctx.getPackageName(), layout);
 contentView.setViewVisibility(, View.INVISIBLE);

I’m well aware that for achieving my goal I will need not documented solution. And I am also aware that UX guidelines strongly recommending to not do such a thing. So there is no point in writing me this as an answer.

How to solve:

It is not good idea to show an icon without show him any related Notification, As per developer docs,

A status bar notification requires all of the following:

  • An icon for the status bar (which you are interested in)
  • A title and expanded message for the expanded view (unless you define a custom expanded view)
  • PendingIntent, to be fired when the notification is clicked to show related info.

So if you don’t want to ruin the User Experience then it’s highly recommendable to follow UX guidelines,

logically: There are two parts of status bar – user (notifications) and system (other). If system allows to put something to system part – there will be so much useless icons (posted by other applications), and there will be no consistency, and it might break all of the use experience.

Found an answer which provide you way to access default status bar icon of Alarm it is here. After Root your mobile you can do it.There are some tricks on youtube doing it, Some answers on same topic suggest to show icon using Notification but put Notification Text empty so that user will only see icon, but again it’s not a way.

This is code for Status bar implementation in System where Left and Right Icons(i.e System Icons) are described may you can get some lead from there. Answer that describe it is here.


I would suggest do not use for usuall Google Play application.
There are several reasons:

  1. If you find a bug which can help to show invisible notification it does seem nothing. The bug can work only in partical device with the particular Android version. Remember: this is very-very hard to setup your regular code be correctly executed in most of devices using opened API. Hidden API doesn’t work in all devices.

    1. There is no such behaviour in the source code: . You can find nothing with such behavoiur.

    2. To predictable behaviour use *Compat classes of Android. That is, for notification use only NotificationCompat class! Only with wrapper can help your app to show notifications.

    3. This is very very ugly UI/UX.

    4. Notifications’ workflow is dramatically depend on Android version.


You can do this using InputMethodService.showStatusIcon(). But I suggest you to display normal notification and explain to user what your app do right now.


you can use RemoteViews to hide title and text

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
    android:layout_height="match_parent" >

        android:src="@drawable/icon_battery" />

in MainActivity:

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_layout);
Context application = getApplicationContext();

Intent resultIntent = new Intent(application, MainActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(application, 0, resultIntent, 0);
NotificationManager nmgr = (NotificationManager) application.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(application)

Notification mNotification =;

//  mNotification.flags |= FLAG_NO_CLEAR;
nmgr.notify(0, mNotification);


Late but maybe useful to others.

In my case its so simple just use height 0dp in your main custom layout like

<RelativeLayout xmlns:android=""

wrap_content will not work here.

Leave a Reply

Your email address will not be published. Required fields are marked *