studio simple notification ejemplo android android-studio notifications android-notifications android-notification-bar

android - simple - Cómo configurar el icono de la aplicación como el icono de notificación en el cajón de notificaciones



notificationmanager android ejemplo (2)

Pruebe este código en su creador de notificaciones:

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

El ícono Set Large hace el truco. Comenta a continuación si tienes más información

Como se muestra en la figura ...
Me aparece el ícono de notificación (a la izquierda del color rojo).
Pero necesito mostrar el ícono de la aplicación como se muestra en la flecha negra

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


Sé que es un poco tarde para responder aquí y también ya fue respondido, pero vine aquí en busca de una solución fácil usando notificaciones de base de fuego. Alguien como yo que esté de visita aquí puede hacer la solución mediante la forma recomendada y fácil de notificación de base de fuego, que es simplemente agregar metadatos en el manifiesto.

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" />