안녕하세요,읽지 않은 알림을 모두 Android에 저장하는 방법은 무엇입니까?
저는 안드로이드에서 새로운데 GCM과 함께 알림을 사용했습니다. 그러나 문제는 상태 표시 줄 아래로 스크롤 할 때 하나 이상의 알림을 하나씩 보내면 마지막 하나만 사용할 수 있다는 것입니다. 상태 표시 줄을 아래로 스크롤 할 때 읽지 않은 모든 알림을 표시하고 싶습니다. 내 코드는 다음과 같습니다.
private static void generateNotification(Context context, String message) {
System.out.println("generateNotification() : "+message);
NotificationMessageModel.msg=message;
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, HomeActivity.class);
notificationIntent.putExtra("message", message);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
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;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
도와주세요 미리 감사드립니다. 코드에서
고맙습니다. Nick T, 그 작업. 하지만 여전히 나는 문제에 대해 어떻게 전 특정 메시지를 설정 id를 얻을. notificationManager.notify (NotificationMessageModel.unreadNotification, notification); NotificationMessageModel.unreadNotification ++; 보류중인 알림을 클릭하면 – Delan
안녕하세요, 저는이 문제를 해결합니다. 하지만 (id, msg) 메소드를 통보하기 위해 고유 한 ID를 추가하면 ID 번호에 따라 아이콘의 수가 표시됩니다. 예를 들어. 3 메시지를 보내면 상태 표시 줄에 아이콘이 3 개 표시됩니다. 개수가 하나 인 아이콘 만 표시하고 싶습니다. – Delan
이 페이지 http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating 여러 메시지에 대해 하나의 알림 아이콘이있는 것을 다룹니다. – NickT