2010-11-05 18 views
9

एंड्रॉइड विकास के लिए नया। मैं सोच रहा हूं कि अधिसूचना बार में डालने के लिए प्रोग्रामेटिक रूप से आइकन आकर्षित करना संभव है? क्या होगा यदि हम चाहते हैं कि आइकन बैटरी स्तर की तरह कुछ गतिशील टेक्स्ट प्रदर्शित करे?एंड्रॉइड अधिसूचना आइकन

यदि किसी के पास कोड नमूना है तो यह अच्छा होगा। धन्यवाद।

+0

क्या आपको इसका समाधान मिला? –

+0

दुर्भाग्य से नहीं। मुझे लगता है कि एक वर्ग को एक पोर्टेबल संसाधन के रूप में संदर्भित करने का एक तरीका होना चाहिए ताकि एक छवि को प्रोग्रामेटिक रूप से खींचा जा सके, लेकिन मैं एंड्रॉइड के बारे में बहुत अधिक समय नहीं जानता या नहीं जानता ... :( –

उत्तर

1
+0

जो मैं नहीं हूं हालांकि, धन्यवाद। मुझे पता है कि अधिसूचना कैसे डाली जाए। मैं अधिसूचना आइकन के लिए फ्लाई पर खींची गई छवि का उपयोग करने के बारे में पूछ रहा हूं। अधिसूचना.किकॉन केवल संसाधन आईडी के लिए एक इंट स्वीकार करता है। –

+0

स्टेटस बार आइकन नहीं हो सकता है। लेकिन आपके द्वारा अधिसूचना का विस्तार करने के बाद दिखाई देने वाला विस्तारित पाठ संभव है। – xandy

+0

उह, जो क्रैपी लगता है। इसलिए स्टेटस बार में किसी आइकन के शीर्ष पर कुछ टेक्स्ट चिपकाने के लिए आपको एक अलग आइकन बनाना होगा प्रत्येक परिदृश्य? –

4

कॉल समारोह जहां हम अधिसूचना चाहते हैं।

public void notification(String name) { 

      final int id = 2; 
      String ns = Context.NOTIFICATION_SERVICE; 
      NotificationManager notificationManager = (NotificationManager) getSystemService(ns); 
      int icon = R.drawable.fbc; 
      CharSequence tickerText = "facebook"; 
      long when = System.currentTimeMillis(); 

      Notification checkin_notification = new Notification(icon, tickerText, 
        when); 
      Context context = getApplicationContext(); 
      CharSequence contentTitle = "You are name is"+ name; 
      CharSequence contentText = "Do You want to Check-in ?? "; 

       Intent notificationIntent = new Intent(context, LoginTab.class); 
       PendingIntent contentIntent = PendingIntent.getActivity(context, 0, 
         notificationIntent, 0); 
       checkin_notification.setLatestEventInfo(context, contentTitle, 
         contentText, contentIntent); 
       checkin_notification.flags = Notification.FLAG_AUTO_CANCEL; 
       notificationManager.notify(id, checkin_notification); 

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