Acceder

Ver la Versión Completa : [ CONSULTA ] Crear notificación al estilo Lollipop


MorSerNa
11/03/15, 19:22:29
Buenas pues tengo una app que me notifica, al tipo Whatsapp, pero estas notificiaciones son las de siempre, y me gustaria aprovechar que tengo en el movil Lollipop, para poder poner las notificaciones a su estilo :P

TIPO ASI http://www.elandroidelibre.com/wp-content/uploads/2014/11/notificaciones-680x403.jpg

kriogeN
11/03/15, 20:20:44
Si usas el NotificationCompat actualizado a la última versión (con la v21 es suficiente) te salen al estilo Lollipop si tienes Lollipop. De lo contrario tendrás que poner como Target a Lollipop, y es muy probable que la notificación falle en móviles con versiones anteriores.

Además debes usar PRIORITY_HIGH, si no el "heads up" no sale.

MorSerNa
11/03/15, 21:26:23
A vale, gracias

Una cosa, por que cuando el móvil esta bloqueado no me llega las notificaciónes de mi app y cuando lo desbloqueo llegan todas a la vez?

MorSerNa
24/03/15, 11:49:47
Me sigue sin salir la notificación te dejo el codigo para que le veas plss :

final NotificationCompat.Builder notificacion = new NotificationCompat.Builder(SocketServicio.this);
notificacion.setSmallIcon(R.mipmap.ic_launcher);
notificacion.setTicker("Temperatura alta de "+codigo1); // Mensaje cuando aparece
notificacion.setWhen(System.currentTimeMillis()); // Hora que mostramos en la notificacion
notificacion.setContentTitle("ˇTemperatura alta!");
notificacion.setContentText(codigo1);
notificacion.setContentInfo(""); // Informacion breve-extra
notificacion.setPriority(Notification.PRIORITY_HIG H);
PendingIntent myPendingIntent;
Intent myIntent = new Intent();
Context myContext = getApplicationContext(); // Actual Activity
myIntent.setClass(myContext, MainActivity.class); // Intent para invocar luego el Activity
myIntent.putExtra("ID", 1); // Mismo ID que la notificacion para luego borrar la notificacion de la barra superior
myPendingIntent = PendingIntent.getActivity(myContext, 0, myIntent, 0); // Intent pendiente de invocar
notificacion.setContentIntent(myPendingIntent);
//ENSEŃAMOS NOTIFICACION
Notification n = notificacion.build();
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(1, n);