Reputation: 91
Is it possible in Android to show notification only when the status bar is expanded? I mean only when I dragged down the status bar, I can see the notification otherwise it will be hidden. If it is possible how I can implement it? I just need to hide the application icon from status bar when it is in the minimal view.Check this
Upvotes: 1
Views: 2520
Reputation: 91
Actually I figured it out myself that from Android 4.1 (API 16) it's possible to specify a notification's priority. If you set that flag to PRIORITY_MIN the notification icon won't show up on the statusbar but you are still able to view the notification on expanding the statusbar.
// Use NotificationCompat.Builder to set up our notification.
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
this).setOngoing(true);
notificationBuilder.setContentTitle("my_title");
notificationBuilder.setSmallIcon(ic_launcher);
// Do other stuffs here.
notificationBuilder.setPriority(Notification.PRIORITY_MIN);// Set this.
Upvotes: 3
Reputation: 25312
Can you add builder.setSmallIcon(...)
to your Notification.Builder
or NotificationCompat.Builder
which you are using.
Code you need to try to get small icon in notification:
// Use NotificationCompat.Builder to set up our notification.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
/* icon appears in device notification bar and right hand corner of
notification */
builder.setSmallIcon(R.drawable.ic_launcher);//Set this
.....
Upvotes: 0