Android Big Picture Style Notification and Big Text Style

I created a push notification using Big Picture Style, as shown here . Can I mix Big Style and Big Text as shown in the attached photo? How to do it?

enter image description here

+5
source share
3 answers

You should be able to do this as follows:

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(); 

A source

+11
source

More ... the text in your notification is a subtext. So when using BigPicturestyle notification you need to set

 bigPicStyle.setSummaryText(mContent); 

or

 mBuilder.setSubText(mSubText); 

Configuring both at the same time does not work.

+3
source

Example of creating 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 full code:

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

0
source

Source: https://habr.com/ru/post/1200581/


All Articles