Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the app icon as the notification icon in the notification drawer

As shown in the figure...
I am getting my notification icon(on left to the red colour).
But I need to display the app icon as shown by the black arrow

enter image description here

    public void notify(View view){     notification.setSmallIcon(R.drawable.ic_stat_name);     notification.setTicker("Welcome to ****");     notification.setWhen(System.currentTimeMillis());     notification.setContentTitle("abcd");     notification.setContentText("abcd");       Intent intent = new Intent(this, home.class);     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);     notification.setContentIntent(pendingIntent);       NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);     nm.notify(uniqueID, notification.build()); } 
like image 306
Aditya Suresh Avatar asked Dec 11 '15 14:12

Aditya Suresh


People also ask

How do I show app icon in notification?

Turn on App icon badges from Settings.Navigate back to the main Settings screen, tap Notifications, and then tap Advanced settings. Tap the switch next to App icon badges to turn them on.

How do I change app notification icons?

1 Tap Notification Settings on the notification panel or tap the Settings app. 2 Tap Notifications. 3 Tap App icon badges.

How do I add an app to my notification panel?

To add an app shortcut, touch the plus button in the lower-right corner of the screen. Scroll through the list of apps and touch an app you want to add to the notification bar. Once you select an app, it's added to the main Bar Launcher screen. To add another app, touch the plus button again and select the desired app.

What are app notification icons?

Basically, these are numbers or little dots that pop up over the corner of a mobile app's logo/icon, thus giving a quick indication that the mobile app in question has a new notification to share. Those dots or numbers are what we call an app icon badge.


2 Answers

I know its bit late to answer here and also its already been answered, but I came here looking for an easy fix using firebase notifications. Someone like me visiting here can do the solution by recommended and easy way of firebase notification, which is simply adding meta-data in manifest.

Reference

<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. --> <meta-data     android:name="com.google.firebase.messaging.default_notification_icon"     android:resource="@drawable/ic_stat_ic_notification" /> <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. --> <meta-data     android:name="com.google.firebase.messaging.default_notification_color"     android:resource="@color/colorAccent" /> 
like image 162
Adam Avatar answered Sep 30 '22 18:09

Adam


Try this code at your notification builder :

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

Set Large icon does the trick.Comment below if you have any further info

like image 31
Manikanta Avatar answered Sep 30 '22 18:09

Manikanta