Android Notification Big Picture Style and Big Text Style

I've build a push notification using Big Picture Style as show here. Is it possible to mix Big picture Style and Big Text Style as shown in the attached photo? How do I do it?

Answers


You should be able to do it this way:

Notification notif = new Notification.Builder(context)
     .setContentTitle("Title")
     .setContentText("content")
     .setSmallIcon(R.drawable.ic_small)
     .setLargeIcon(bitmap)
     .setStyle(new Notification.BigPictureStyle()
         .bigPicture(bigBitmap)
         .setBigContentTitle("big title"))
     .build();

Source


View More... text in your norification is subtext. So while using bigpicturestyle notification you need to set

bigPicStyle.setSummaryText(mContent);

or

mBuilder.setSubText(mSubText);

Setting both at same time doesn't work.


Example of how to create a BigPictureStyle Notification:

 int NOTIFICATION_ID = 1;
    String ns = Context.NOTIFICATION_SERVICE;

    //Get the bitmap to show in notification bar
    Bitmap bitmap_image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

    Bitmap big_bitmap_image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);


    NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle()
            .bigPicture(big_bitmap_image)
            .setSummaryText(getResources().getString(R.string.content));

    NotificationCompat.Builder nb = new NotificationCompat.Builder(this);

            nb.setContentTitle("Notification title"))
            .setContentText("Notification Content")
            .setSmallIcon(R.drawable.ic_launcher)
            .setLargeIcon(bitmap_image)
            .setTicker("Notification ticker!")
            //API Level min 16 is required
            .setStyle(style)
            .build();


    Intent notificationIntent = new Intent(this, MainActivity2.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    TaskStackBuilder TSB = TaskStackBuilder.create(this);
    TSB.addParentStack(MainActivity.class);

    TSB.addNextIntent(notificationIntent);
    PendingIntent resultPendingIntent = TSB.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    nb.setContentIntent(resultPendingIntent);
    nb.setAutoCancel(true);
    NotificationManager mNotificationManager =
            (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    mNotificationManager.notify(NOTIFICATION_ID, nb.build());

this is the complete code:

https://github.com/Jorgesys/Android-Notifications


Need Your Help

Test if actor sender was local or remote

akka akka-cluster

I need to determine whether the sender of a message was one of the local or remote actors in the Akka cluster. At present the only way I've found to do this is

Exception on XML sorting

c# xml linq exception sorting

I'm trying to sort elements from an XML file in LINQ by an element's attribute: