Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notification buttons not showing up

This is my code to set up a notification with buttons.

Intent receiverIntent = new Intent(ctx, ResponsivePrefsActivity.class);         PendingIntent pReceiverIntent = PendingIntent.getActivity(ctx, 1, receiverIntent, 0);         Intent clearIntent = new Intent(ctx, ResponsivePrefsActivity.class);         clearIntent.setAction("clear");         PendingIntent pClearIntent = PendingIntent.getActivity(ctx, 1, clearIntent, 0);          Intent colorsIntent = new Intent(ctx, ResponsivePrefsActivity.class);         colorsIntent.setAction("colors");         PendingIntent pColorsIntent = PendingIntent.getActivity(ctx, 1, colorsIntent, 0);          Intent animationIntent = new Intent(ctx, ResponsivePrefsActivity.class);         animationIntent.setAction("animation");         PendingIntent pAnimation = PendingIntent.getActivity(ctx, 1, animationIntent, 0);          Notification.Builder builder;         builder = new Notification.Builder(ctx).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(false)                 .setContentTitle("Draw Me: A Live Wallpaper").setContentText("Never get bored again!")                 .setContentIntent(pReceiverIntent).addAction(R.raw.ic_menu_close_clear_cancel, "Clear", pClearIntent)                 .addAction(R.raw.ic_menu_edit, "Colors", pColorsIntent).addAction(R.raw.ic_menu_play_clip, "Animation", pAnimation);         Notification notification = builder.build();          NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);          notificationManager.notify(0, notification); 

Notification is showing up but buttons don't. My device has Android 4.1.1 I set up this notification in a Fragment. What am I doing wrong? Thanks!

like image 888
DraganescuValentin Avatar asked Aug 15 '13 09:08

DraganescuValentin


People also ask

How do I turn on notification status bar?

The user can reveal the Notifications window by pulling down the status bar (or selecting Notifications from the Home options menu).

Where is notification drawer?

The Notification Panel is at the top of your mobile device's screen. It is hidden in the screen but can be accessed by swiping your finger from the top of the screen to the bottom.


2 Answers

Let me tell you something which is really awkward. If you have anything in your Ongoing Notification, You wont see the buttons. Typically it happens when you have phone connected to PC via USB. Hope this solves your problem

like image 51
CommonMan Avatar answered Sep 28 '22 00:09

CommonMan


Just a reminder for anyone with a similar issue. As per the Android Notifications Guide, notifications can appear in two styles:

  • Normal View, where the action buttons don't appear by default (and the user has to expand the notification, in order for them to appear)
  • Big View, which is visible if the notification is first in the notification list, or the user has expanded the notification.

Therefore in order to force the notification to appear in Big View, all we have to do is simply place it on the top of the Notifications list. That can be done by setting the When property to 0 which makes it the oldest among notifications! (Sometimes though we may not want this). So call

setWhen(0) 

to your notification and you're done.

like image 38
paulahniuk Avatar answered Sep 28 '22 01:09

paulahniuk