.setWhen(System.currentTimeMillis())
est le code pour définir l'heure dans la notification push android et le résultat est comme 15.54
. Mais si je veux mettre le temps comme ça 15:54:02
avec secondes, que dois-je faire? Pouvez-vous m'aider ou me fournir un exemple de code source?Comment puis-je régler l'heure et la date de notification une seconde fois?
Ceci est mon code source de notification-manager.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mCtx);
Notification notification;
notification = mBuilder.setSmallIcon(R.drawable.logo).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentIntent(resultPendingIntent)
.setContentTitle(title)
.setSmallIcon(R.drawable.logo)
.setWhen(System.currentTimeMillis())
.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher))
.setContentText(message)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults = Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults = Notification.DEFAULT_ALL;
int id = (int) System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager) mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(ID_SMALL_NOTIFICATION, notification);
notificationManager.notify(id, notification);
}
Ce tripoter 'notification.defaults' semble me non-sens. Je voterais pour enlever cela pour ne pas dérouter les lecteurs, à la fois ici et dans la base de code réelle. –