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
Asked
Active
Viewed 2,197 times
1
-
Duplicate of http://stackoverflow.com/questions/20798565/can-i-force-expand-android-notification-on-android-4-1 – Kelevandos Dec 16 '15 at 09:23
-
@Kelevandos, I don't need to display the notification in expanded view forced. I want to remove the icon from the status bar when it not expanded. – Jithin Dec 16 '15 at 09:49
-
Then please edit your question to reflect that :-) – Kelevandos Dec 16 '15 at 09:52
2 Answers
3
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.

Jithin
- 91
- 9
0
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
.....

pRaNaY
- 24,642
- 24
- 96
- 146
-
Thanks for your help, but I want to remove that icon from the status bar when the status bar is not expanded. – Jithin Dec 16 '15 at 10:12