मैं अपने आवेदन में कई अधिसूचनाएं बनाने की कोशिश कर रहा हूं। प्रत्येक अधिसूचना को विशिष्ट रूप से पहचानने के लिए, मैंने उन्हें एक अद्वितीय पहचान दी है। बाद मेरी कोड है:एंड्रॉइड: एकाधिक अधिसूचनाएं प्रबंधित करना
private void updateNotification(int notificationId, int clockStatusID, CharSequence text) {
//notificationManager.cancel(notificationId);
// throws up an ongoing notification that the timer is running
Log.i("TIMERCOUNT", "Notification id: " + notificationId);
Notification not = new Notification(clockStatusID, // the
// icon
// for
// the
// status
// bar
text, // the text to display in the ticker
System.currentTimeMillis() // the timestamp for the
// notification to appear
);
Intent intent = new Intent();
intent.putExtra("notificationID", notificationId);
intent.setAction("actionstring" + System.currentTimeMillis());
intent.setClassName("com.chander.time.android.activities",
"com.chander.time.android.activities.Tabs");
not.setLatestEventInfo(self,
getText(R.string.timer_notification_title),
getText(R.string.timer_on_notification_text), PendingIntent
.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT));
not.flags += Notification.FLAG_ONGOING_EVENT;
not.flags += Notification.FLAG_NO_CLEAR;
notificationManager.notify(notificationId, not);
}
समस्या: जब कोई सूचना चुना जाता है, टैब्स गतिविधि आशय गुजर कहा जाता है। मैं टैब में चयनित अधिसूचना की अनन्य अधिसूचना आईडी का उपयोग करना चाहता हूं। इरादे में अधिसूचना आईडी को बचाने के लिए मैंने intent.putExtra() की कोशिश की। लेकिन, कई अधिसूचनाओं के लिए यह अधिसूचना आईडी को ओवरराइट कर रहा है और नवीनतम लौटाता है। मैं समझ नहीं पा रहा हूं कि यह क्यों हो रहा है और मैं अधिसूचना आईडी के इस ओवरराइटिंग से कैसे बच सकता हूं।
धन्यवाद, चंदर