0

Я не нашел ни одного решения в Интернете, которое решает проблему.Мне нужно приложение для Android, чтобы показать несколько уведомлений

int notificationId = Integer.parseInt(Common.getStringSharedPreference(context, "NOTIFICATION_ID", "ID", "1")); 

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
    Notification notification = new Notification(R.drawable.app_logo, message, System.currentTimeMillis()); 
    String title = context.getString(R.string.app_name); 
    Intent notificationIntent = null; 
    notificationIntent = new Intent(context, MyLawyerActivity.class); 
    notificationIntent.putExtra(ExtrasKeys.ITEM_OBJECT, (Serializable) object); 
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); 
    PendingIntent intent = PendingIntent.getActivity(context, notificationId, notificationIntent, 0); 
    notification.setLatestEventInfo(context, title, message, intent); 
    notification.flags |= Notification.FLAG_AUTO_CANCEL; 
    notification.flags |= Notification.FLAG_SHOW_LIGHTS; 
    notification.defaults |= Notification.DEFAULT_SOUND; 
    notification.sound = Settings.System.DEFAULT_NOTIFICATION_URI; 
    notification.defaults |= Notification.DEFAULT_VIBRATE; 
    notificationManager.notify(0, notification); 

    Common.putStringSharedPreference(context, "NOTIFICATION_ID", "ID", ""+(notificationId+1)); 

Обратите внимание, что я использую устройство с леденцом для тестирования.

+0

хасана вы должны использовать другой идентификатор для каждого уведомления ...... notificationManager.notify (ЗДЕСЬ, уведомление); – koutuk

+0

Спасибо @koutuk, он дал ответ перед вашим исходным комментарием на 5 секунд :) – hasan83

+0

не проблема ... :) – koutuk

ответ

2

Просто измените номер для многократного уведомления как

notificationManager.notify(0, notification); 
notificationManager.notify(1, notification); 
+0

так что там, где должен идти идентификатор! и не здесь PendingIntent.getActivity (context, notificationId, notificationIntent, 0); так что это за то, что я настраиваю? – hasan83

+0

О, это код запроса! :) – hasan83

+0

yeah ........... –

Смежные вопросы