Playing with this for three hours and can't figure what's wrong.
private static Notification buildNotification(Context context) {
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setContentIntent(PendingIntent.getActivity(
context, 0, new Intent(context, MyActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT));
b.setTicker(context.getString(R.string.update_notification_title));
b.setContentTitle(context.getString(R.string.update_notification_title));
b.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.icon));
b.setSmallIcon(R.drawable.icon);
b.setOngoing(true);
b.setAutoCancel(false);
b.setProgress(100, 0, true);
Intent cancel = new Intent(context, Updater.class);
cancel.putExtra(EXTRA_CANCEL, true);
b.addAction(
R.drawable.discard_holo_dark,
context.getString(R.string.ui_cancel),
PendingIntent.getService(context, 0, cancel, PendingIntent.FLAG_UPDATE_CURRENT));
return b.build();
}
I tried the default NotificationBuilder on JellyBean as well. Also been trying to change PendingIntent to getActivity and tried to replace icons and text as well. Tried to setOngoing(false), without progress and with autoCancel. Still no luck seings by buttons. Tried on four different devices.
NotificationCompat.Builder will not show Actions on Android < 4.1
On some devices, if there are multiple notifications, the notification with actions appear collapsed. Swiping down on the notification with two pointers gesture expands the actions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With