6

La barra de notificaciones en mi aplicación muestra solo el ícono pequeño en el teletipo (como debería). Sin embargo, cuando se baja el "sombreado", muestra tanto el ícono pequeño del teclado como un ícono grande que configuré en Notification.Builder. Aquí está mi código:La barra de notificaciones muestra iconos grandes y pequeños

if (Build.VERSION.SDK_INT > 10){ 
      notification = new Notification(R.drawable.ic_stat_mintchip, 
        "This is a test", 
        System.currentTimeMillis()); 
      notification.largeIcon = (((BitmapDrawable)c.getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()); 
      notification.defaults |= Notification.DEFAULT_ALL; 
      notification.number += 1; 
      notification.flags |= Notification.FLAG_AUTO_CANCEL; 

     } else { 
      notification = new Notification(R.drawable.ic_stat_mintchip, 
        "This is a test", 
        System.currentTimeMillis()); 

       notification.flags |= Notification.FLAG_AUTO_CANCEL; 
       notification.defaults |= Notification.DEFAULT_ALL; 
       notification.number += 1; 
     } 
} 

No sé muy bien por qué sucede esto. ¿Alguna ayuda?

+1

Se puede publicar una captura de pantalla en alguna parte de lo que está viendo? – CommonsWare

+0

Claro, un segundo ... http://imgur.com/07lxg – D4N14L

+1

Supongo que usted es MintChip. No estoy muy seguro de por qué estás obteniendo ese efecto. ¿Qué dispositivo es este? Tenga en cuenta que, aunque su pregunta dice que está utilizando 'Notification.Builder', su código no lo está. Puede considerar usar 'NotificationCompat.Builder' del proyecto de soporte de Android y ver si eso ayuda. – CommonsWare

Respuesta

11

Creo que el problema aquí es posiblemente que no esté utilizando la clase Notificaiton.Builder. He aquí un pequeño ejemplo de lo que podría hacer (que tendría que insertar sus propias variables embargo, y establecer las otras propiedades que utilizó como la vibración):

Notification.Builder nb = new Notification.Builder(context) 
    .setContentTitle("title") 
    .setContentText("content") 
    .setAutoCancel(true) 
    .setLargeIcon(largeIcon) 
    .setSmallIcon(R.drawable.small_icon) 
    .setTicker(s.getText()); 
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 
nm.notify(100, nb.build()); 
+0

Funcionó a la perfección :) – D4N14L

+1

No puedo compilar el 'nb.build()' en Android4.04, utilizo nb.getNotification() en su lugar. – herbertD

+0

si uso un ticker, ¿qué icono se usa? ¿y cómo puedo personalizarlo y usar uno diferente para él y uno diferente para la notificación en sí? –

7

Otro problema que tuve en piruleta Android es que el un pequeño ícono fue mostrado al lado del ícono grande. Para resolverlo, ¡simplemente no configure el icono grande! Use solo la configuración de icono pequeño.

+1

Pero quiero usar ambos. ¿Alguna forma de hacer esto? – vedant1811

+0

Si configura ambos iconos, aparecerán ambos. – ravyoli

+3

ver http://stackoverflow.com/a/33943309/218473 sobre cómo ocultar el icono pequeño – Maragues

Cuestiones relacionadas