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:
- It creates a notification, but its all black
- I don't want it to be expanded like this
- 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.