I wanted to display a bigPictureStyle Notification in MiUi(don't want to use custom view) using the following code--
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(msg)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.b))
.setBigContentTitle(title));
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(10, mBuilder.build());
It works perfectly on raw android but in Xiaomi MIUI 8 (Android Lollipop based) it shows a shadow at the bottom of expanded notification view as in the picture--
How to remove this bottom shadow?
The only solution for now is using a custom view with similar looking big content view.
Related
In push notification, the small icon is not showing in 7.1.1 above OS.White square like coming
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
Notification notification = mBuilder.
setSmallIcon(R.drawable.notification_icon).
setTicker("testing").setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(contentIntent)
.setSound(defaultSoundUri)
.setContentText(message)
.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, notification);
I'm using transparent background but I'm not able to show correctly please help me.Even I follow the android icon design guidelines.
i'm trying to put expand icon in notification on my developing app. I already done notification RemortView collapse and expand Layout helping with this site.Below pitcher is my current status of my notification.
My Code given below:
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
builder.setContentIntent(intent);
builder.setTicker(mContext.getResources().getString(R.string.custom_notification));
builder.setSmallIcon(R.drawable.ic_notification_small_basket);
builder.setAutoCancel(true);
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
builder.setCustomBigContentView(expandedView);
builder.setCustomContentView(contentView);
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
Actual my need is how to put expand icon and how to get that clicking event from notification RemortView using for expand and collapse the notification.
Look like below pitcher.
This pitcher is just a example for that expand icon.
please assist me.
I know its an old question, but for the sake of the nature of Stack Overflow, I'll give you a proper answer.
Instead of implementing your own header including an arrow to expand/collapse the notification, you might want to decorate your custom notifiction with Androids default header.
The only thing you should take care about is to use the builder methods in the proper order to accomplish your task.Fist you have to set the remote views for collapsed and expanded RemoteViews (what you call RemortViews), and THEN you wrap the NotificationCompat.DecoratedCustomViewStyle around it.
notificationBuilder.setCustomContentView(contentView)
.setCustomBigContentView(expandedView)
.setStyle(NotificationCompat.DecoratedCustomViewStyle()) // <- That's what you want
val notification = notificationBuilder.build()
Do not forget to delete your custom header stuff as it does not make sense anymore.
Click here for the documentation
OK now that we have code I tried this and it worked for me you will need to do some adjustments on where and what is stored
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
R.mipmap.ic_launcher))
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
android.app.NotificationManager notificationManager =
(android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
Hello I have implemented Push notifications in my application.
It's working fine and displaying notification icon properly for the devices below nougat version.
But, It displaying notification icon as Square with color white.
Below is my code :
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.app_icon)
.setColor(ContextCompat.getColor(getApplicationContext(),R.color.white))
.setContentTitle(strTitle)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(++NOTIFICATION_ID /* ID of notification */, notificationBuilder.build());
First of all , this is not an error. It is a change in the design with Android Nougat
For Android Nougat, you should provide rounded icon for notification.
Check out this link and this for more details.
How can I remove the secondary smaller icon on the bottom right of a notification? Since it's required that we call the setSmallIcon method for the notification, we can’t just remove the call for this method.
Is there any way to remove the secondary icon while retaining it on the status bar? Do we have to call setStyle and set a custom style for the notification?
I got rid of it like that (works for Android 5 and below):
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap notificationLargeIconBitmap = BitmapFactory.decodeResource(
context.getResources(),
R.drawable.notification_icon_big);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notification_systray)
//.setLargeIcon(notificationLargeIconBitmap)
.setContentTitle(context.getString(R.string.app_name))
.setContentText(msg)
.setColor(context.getResources().getColor(R.color.blue))
.extend(new NotificationCompat.WearableExtender().setBackground(notificationLargeIconBitmap));
I have created a notification with NotificationCompat.Builder but i don't know how to show it in status bar. I tried using
NotificationManager notificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mId, mBuilder.build());
but it doesn't work on 2.2 so i need another way...
this is my notification
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification)
.setContentTitle("Message")
.setContentText("Notification");
but it doesn't work on 2.2
Yes it does.
This sample application shows an IntentService downloading a file and displaying a Notification using NotificationCompat.Builder. It uses code pretty much like yours for actually raising the Notification:
NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mgr.notify(NOTIFY_ID, b.build());
This code works fine on Android 2.2, as I just tried it (again) on an emulator, and the Notification displays as expected.