Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you have not posted any code. So I am sharing my code which worked for me:</p> <pre><code>public static void notifyIcon(Context context){ NotificationManager notifier = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.your_app_notification, "", System.currentTimeMillis()); /** *Setting these flags will stop clearing your icon *from the status bar if the user does clear all *notifications. */ notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification_layout); notification.contentView = contentView; //If you want to open any activity on the click of the icon. Intent notificationIntent = new Intent(context, YourActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.contentIntent = contentIntent; notification.setLatestEventInfo(context, "title", null, contentIntent); notifier.notify(1, notification); //To cancel the icon ... notifier.cancel(1); } </code></pre> <p>Here is custom_notification_layout.xml</p> <pre><code>&lt;?xml version = "1.0" encoding = "utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="3dp" &gt; &lt;/LinearLayout&gt; </code></pre> <p>Note: Don't forget to clear your app icon when appropriate If you set above flag.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload