title: How do I show text in android system status bar
body: <p>I'm trying to develop an app for Android Nougat and I want to show some info/text in the status bar generating from a android service routine. So my problem is, I don't know how to show the text in the status bar.</p>
  
  <p>I added a sample image to show what exactly do I mean (red circle). 
  I know it is possible, because I saw it in a battery monitor app from play store.</p>
  
  <p><img src="https://i.stack.imgur.com/rbPKQ.png" alt="Sample"></p>
  
  <p>I already tried NotificationCombat.Builder, but I think this is not the right way. Maybe an overlay is, but after searching I didn't find something.</p>
  
  <p>Can someone show me how to do it or give me a hint, please?</p>
  
  <p>Edit: Here my test code for NotificationCompat.Builder</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>import android.app.Notification;
  import android.app.NotificationManager;
  import android.os.Bundle;
  import android.support.v4.app.NotificationCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  
  public class MainActivity extends AppCompatActivity
  {
      private final int NOTIFICATION_ID = 10;
  
      @Override
      protected void onCreate (Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
          mBuilder.setContentTitle("Value");
          mBuilder.setContentText("123");
          mBuilder.setSmallIcon(R.mipmap.ic_launcher);
          mBuilder.setOngoing(true);
          mBuilder.setAutoCancel(false);
  
          //Intent resultIntent = new Intent(this, MainActivity.class);
          //PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
          //mBuilder.setContentIntent(resultPendingIntent);
  
          Notification notification = mBuilder.build();
          notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
  
          NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          mNotifyMgr.notify(NOTIFICATION_ID, notification);
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".MainActivity"&gt;
  
      &lt;android.support.design.widget.CoordinatorLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
                                                      android:layout_width="match_parent"
                                                      android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
              &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar"
                                                 android:layout_width="match_parent"
                                                 android:layout_height="wrap_content"
                                                 android:background="#000000"
                                                 app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
          &lt;/android.support.design.widget.AppBarLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:orientation="vertical"
              app:layout_behavior="@string/appbar_scrolling_view_behavior"
              android:weightSum="100" &gt;
  
              &lt;TextView
                  android:id="@+id/tv_value"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Hello World!"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintLeft_toLeftOf="parent"
                  app:layout_constraintRight_toRightOf="parent"
                  app:layout_constraintTop_toTopOf="parent"/&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/iL3g8.png" alt="Result 1"></p>
  
  <p><img src="https://i.stack.imgur.com/BoOYh.png" alt="Result 2"></p>