Show only large icon when notification pulled in android - android

In my application i need to show the notification using native android api.
I am showing the notification by settings small and large icons.In recent OS devices (from 4.4) application is showing both small and large icons .
is there anyway to hide small icon when user pull notification and only show the large icon.
I have searched for the answers,but did not find working solution.
Below is the code i am using .
`Notification.Builder builder = new Notification.Builder(getApplicationContext())
.setContentTitle("Title")
.setContentText("Content")
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.pull_down_icon);
.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND);
Notification mNotif = builder.build();
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, mNotif);`
below is my observations.
- when i set only small icon, then small icon is displayed for notification bar and when user pull the notification same icon is displayed.
- when i set both (small and large) notification shown the small icon but, when user pull it shows both small and large

Related

Android Notification - Small icon not working on some devices

According to https://developer.android.com/training/notify-user/build-notification#java I am creating a notification correctly.
I expect something as:
My code is:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "channel")
.setSmallIcon(R.drawable.wesay_not)
.setContentTitle(notification.title)
.setContentText(notification.description)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setChannelId(context.getString(R.string.channel_id));
And the drawable is there:
However the device is showing the default android one, other applications seem to be showing the icon ok:
Probably that device you are using is xxxhdpi. and somehow it is taking default icon for those devices.
I suggest you remove your default icon from your project if you are not using it. And you can use Notification Icon Generator for generating icons for all size.
Ah, I just noticed that the XXHDPI icon is 128x128 and it should be 72x72, probably that has to do
find default icon named "wesay_not" in whole project first. If found than replace it with actual icon with folder related size.

how to remove small notification icon in android studio apps

I'm building an android app which shows a notification when it's running. But the notification icon doesn't take the full size. Here is the code and an image of it.
NotificationCompat.Builder notificationBuilder=new
NotificationCompat.Builder(getActivity())
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.mipmap.ic_launcher);
enter image description here
when I set 'large icon', it takes the full size.
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
enter image description here
What I wanted to do is, remove the small icon and only keep the large icon which shows as a bigger icon. But if I removed 'setLargeIcon(int)' and keep 'setLargeIcon(bigmap)', app doesn't show any notificaitons. So in order to get notifications I have to keep both icons.
Could anyone give a solution for this. How can I keep only the large icon ?

Notification large icon always green robot

I try to show notification using NotificationCompat.Builder:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.ic_notification_small);
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_notification_large));
builder.setContentTitle(context.getString(R.string.push_notification_received_title));
builder.setContentText("message");
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
.notify(MESSAGE_NOTIFICATION_ID, builder.build());
But, instead large icon that I pointed on the builder in notification I get icon with a green robot (default icon like ic_luncher). I suppose problem may be that I use xiaomi device, but some applications like google translate show normal large icon.
After some of time I found a problem. Some of the shell (such as xiaomi) get large notification icon from launcher icon, so need to change launcher icon, reinstall application and reboot device for the changes to take effect (because icons placed in the cache).

How to show secondary notification icon when using a large icon?

When setting a large icon in the push notification, the secondary notification is empty. In the status bar the app of the application is displayed but when opening to see the notification its empty.
here is the link of the notification that i get: http://i.stack.imgur.com/XHoxY.jpg
Here is my code:
new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setTicker(title) .setContentText(msg).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
If I change the target to android:targetSdkVersion="20" it works. But if using a greater SDK it doesn't display the smallicon
Per the notification style guidelines, notification icons must be a flat icon - on Android 5.0+ devices, any non-transparent pixels are changed to solid white as seen by your small icon showing a solid square.

Unexpected Icon and background color for Android Wear notification

I am working on an app that sends notifications using the NotificationManager. I set up an Android Wear emulator and have my android phone connected to the emulator. The notifications my app generates appear on the Android Wear emulator, but the icons and color used are not what I'd expect.
The notification uses 1 of 3 icons as the notification icon, and sets a different LED color for each of the 3 cases. The notification I see on the watch emulator uses the app icon, and not the icon I set in the notification. Also, the background color of the notification is a solid red background, and I'm not sure what's setting it that color.
How can I get my notifications on the watch to match the icon of the notification I set, and how can I change the BG Color?!
Below, the Pink box is the application icon (and not the notification icon I'd expect).
Watch Notification
The notification icons come from the res/drawable folders of the handheld app. Do you have an icon with the same name in the res/drawable-hdpi folder?
http://developer.android.com/training/wearables/notifications/creating.html
Note: The bitmap that you use with setBackground() should have a resolution of 400x400 for non-scrolling backgrounds and 640x400 for backgrounds that support parallax scrolling. Place these bitmap images in the res/drawable-nodpi directory of your handheld app. Place other non-bitmap resources for wearable notifications, such as those used with the setContentIcon() method, in the res/drawable-hdpi directory of your handheld app.
As far I know the colors of the LED are irrelevant for wearable notifications. The background color is selected by default the icon and its priotity, if you set a big icon image it will use this. Since the quality of that big icon image meight be bad there is another call to achieve that. Here is a full example:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle("title")
.setContentText("message")
// replace the drawable if you want something else
.setSmallIcon(R.drawable.ic_launcher);
NotificationCompat.WearableExtender extender =
new NotificationCompat.WearableExtender();
Bitmap bg = BitmapFactory.decodeResource(context.getResources(),
R.drawable.background);
// in the line above you can change the background image
extender.setBackground(bg);
builder.extend(extender);
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
notificationManager.notify(42, builder.build());

Categories

Resources