Notification Bar with BigPictureStyle and 2 lines text?

2

I need to make a notification like this:

Ihavetriedeverythingandcannotfindanythinglikeit.

Iwasabletoput2buttonsbelowtheimagewith:

.addAction(R.drawable.sim,"Sim", pendingIntentYes)
            .addAction(R.drawable.nao, "Não", pendingIntentNo)

But really what I need and I can not at all is to put TWO lines or break text in setSummaryText.

Do I need to make a custom notification? If so, how can I do it this way?

Edit:

That was exactly what I needed, someone knows how to make a notification like that.

    
asked by anonymous 29.11.2015 / 18:55

1 answer

1

To display the 3 lines of text plus the text "info" you have to do this:

Notification notif = new NotificationCompat.Builder(this)
                .setContentTitle("Title")
                .setContentText("Text")
                .setSubText("SubText")
                .setContentInfo("info")

When setting BigPictureStyle like this:

NotificationCompat.BigPictureStyle big = new NotificationCompat.BigPictureStyle();
big.bigPicture(bitMap)
   .setBigContentTitle("BIG TITLE")
   .setSummaryText("SUMMARY");

When Notification is displayed expanded:

  • "Title" is replaced by "BIG TITLE"
  • the text "Text" is retained.
  • the text "SubText" is replaced by "SUMMARY"

It is also possible to create custom notifications using a RemoteViews and pass it to the Notification.Builder% method

Set your layout as usual in xml , then build the Notification this way:

RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.customnotification);
Notification.Builder builder = new Notification.Builder(this) 
        ...
        ... 
        ... 
        .setContent(remoteViews);

Use the various methods provided by RemoteViews to access the views of the layout .

For example setContent() assigns a pendingIntent to the remoteViews.setOnClickPendingIntent(R.id.button1, intent);

    
29.11.2015 / 19:25