0

I am new to android. I have created FCM large notification. Now what I want to do, how can I make notification like image Large Imag I trying to make it large icon but I filed. Thank you for help.

enter image description here

FcmMessagingService : java

private void ManualNotification(String title, String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString("message", messageBody);
    intent.putExtras(bundle);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    Bitmap bmp = BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher);
    Notification.BigPictureStyle bigpicture = new Notification.BigPictureStyle();
    bigpicture.bigPicture(bmp);
    NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notifcation)
            .setContentTitle(title)
            //.setContentText(messageBody)
            .setLargeIcon(bmp)
            .setContentIntent(pendingIntent)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
            .setContentText(messageBody).setLights(Color.YELLOW, 300, 300)
            .setVibrate(new long[]{100, 250})
            .setDefaults(Notification.DEFAULT_SOUND)
            .setAutoCancel(true);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • you have `BigTextStyle` in setStyle and you also want the BigPictureStyle to be in the notification when expanding, so check this https://stackoverflow.com/questions/36232394/android-notification-with-bigpicture-style-and-bigtext-style – Peter Haddad Jan 25 '18 at 12:02

2 Answers2

1

you can use this link for notification icon size:

notification icon size in android

or if you want to create your custom notification view then you can use RemoteView for that. See sample:

android custom notification tutorial

Ali Habbash
  • 777
  • 2
  • 6
  • 29
aj0822ArpitJoshi
  • 1,142
  • 1
  • 9
  • 25
0

Try with Notification class:

final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(Context context, String channelId);
Notification notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setContentIntent(resultPendingIntent)
                .setSound(alarmSound)
                .setStyle(bigPictureStyle)
                .setWhen(getTimeMilliSec(timeStamp))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
                .setContentText(message)
                .build();
Akshay
  • 6,029
  • 7
  • 40
  • 59