2010-08-06 16 views
6

मैं एक बहु बंद घड़ी आवेदन बनाने रहा हूँ में एक से अधिक सूचनाएं प्रबंधित करना जिसके लिए वहाँ कई समानांतर चल टाइमर, और प्रत्येक सूचना प्रत्येक टाइमर से आबद्ध हो जाएगा।एंड्रॉयड: स्थिति पट्टी

मैं निम्नलिखित कोड के साथ कई टाइमर बनाने में सक्षम हूं।

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.setClassName("com.intuit.time_catcher.android.activities", 
    "com.intuit.time_catcher.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); 

} 

निम्नलिखित समस्या का सामना करना पड़ रहा है। मान लें कि स्थिति बार में 3 टाइमर चल रहे हैं और 3 अधिसूचनाएं हैं। जब मैं टाइमर 2 अपडेट करता हूं, अधिसूचना 3 (जो कि सबसे ऊपर है) अद्यतन हो जाता है, लेकिन मैं वास्तव में क्या करना चाहता हूं दूसरी अधिसूचना (मध्य एक) को अद्यतन करना है। जब मैं अधिसूचना आईडी मुद्रित करता हूं, तो मैं सही मान देख रहा हूं। मैं समझ नहीं पा रहा हूं कि मुझे यह अजीब व्यवहार क्यों मिल रहा है?

उत्तर

4

ऐसा लगता है कि अपने उद्देश्य कैश नहीं किया जाता है एक अद्वितीय setAction('anystring'+timestamp) या गिनती मूल्य जोड़ने

प्रयास करें, यह के रूप में इस question

intent.setAction("actionstring" + System.currentTimeMillis()); 
+0

मैंने कोशिश की, लेकिन अभी भी एक ही समस्या हो रही है –

+0

intent.setAction() के बजाय मैंने intent.setData() का उपयोग किया और यह काम किया –

1

एक आवेदन में बताया गया है अद्वितीय होना चाहिए (जो कारखाने डिफ़ॉल्ट है) ऑर्डर नोटिफिकेशन को वास्तव में सीधे नियंत्रित नहीं किया जा सकता है ... क्या आप उन्हें फिर से ऑर्डर कर रहे हैं?

भी तीन अधिसूचनाएं पोस्ट करना बहुत स्पष्ट है। एक होने के बारे में क्या, किसकी सामग्री सभी 3 टाइमर की स्थिति दिखाती है?

संबंधित मुद्दे