private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
Notification notification = null;
try {
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(NOTIFICATION_SERVICE);
notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
} catch (Exception e) {
Log.i(TAG, " setNotification Exception : " + e.getMessage());
}
}
notiication부분 소스입니다.
push를 이용하여 메세지만 받는 구조인데요
첫번째 메세지와 두번째 메세지의 내용이 다를경우 notification에 2개의 리스트로 떳으면 하는데,
현재는 메세지의 내용만 바뀐채 하나의 notification으로 뜹니다.
내용이 다를때 리스트 형태로 쌓이게 하는 방법좀 알려주세요 ㅠㅠ(아이폰처럼)
notificationManager.notify(0, notification);
에서 0 을 (int)System.currentTimeMillis() 처럼 매번 다른 값을 넣으시면 될것 같은데요.