0

I think that the usual way to display actions in android is a little bit hard to tap and to be found. The user needs to perform two actions (swipe the notification, then click the action).

So I want to add a button to the right side of the notification, so it will be easier to tap.


The only way I found to to this is to use a MediaStyle, but it has some issues:

  1. It creates a notification, but its all black

Contracted

  1. I don't want it to be expanded like this

Expanded

  1. I want to add the usual action (a cog icon, shortcut to the config screen)

The code I've got so far:

Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
    .setSmallIcon(R.mipmap.ic_launcher_round)
    .setContentTitle("WorkTime")
    .setContentText("Estimativa de saída: 19:00h")
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
    .setOngoing(true)
    .addAction(R.drawable.ic_fingerprint_black_24dp, "bater ponto", null)
    .setStyle(
        new android.support.v4.media.app.NotificationCompat.MediaStyle()
            .setShowActionsInCompactView(0)
    )
    .build();

notificationManager.notify(1, notification);

Will I need to implement a custom layout for the notification?

PS: As you will probably notice, the smallIcon didn't work. Some tip will be apreciated, but I know that would be another question, and I think I can find the solution on my own.

Ian
  • 2,944
  • 1
  • 19
  • 19

1 Answers1

0

You need to set a large icon on the notification

greywolf82
  • 21,813
  • 18
  • 54
  • 108
  • I believe largeIcon is only available on Android N+. My phone is still an Android M. Also, I don't think that the large icon can have an action – Ian Apr 26 '18 at 23:32