मैं एक ऐसे अनुप्रयोग पर काम कर रहा हूं जो अग्रभूमि सेवा का उपयोग करता हो। इस उद्देश्य के लिए मैं सेवा के स्टार्ट कमांड कॉलबैक के अंदर से startForeground(id,Notification)
पर कॉल कर रहा हूं।एंड्रॉइड: अग्रभूमि प्रारंभ करें अधिसूचना ठीक से प्रदर्शित नहीं करें
मैं अपनी अधिसूचना बनाने के लिए एक अधिसूचना निर्माता का उपयोग करता हूं लेकिन जब मैं इसे प्रारंभ करने के लिए पास करता हूं तो केवल टूरर टेक्स्ट प्रदर्शित होता है जैसा कि मैंने इसे सेट किया है, बाकी सब कुछ डिफ़ॉल्ट हो जाता है, यानी शीर्षक कहता है "जब मैं इसे सेट करता था तब चल रहा है "ऑनलाइन है"
कुछ भी जो मैंने अधिसूचना में सेटटेक्स्ट और सेटइन्फो विधि का उपयोग करके सेट किया था। बिल्डर इसके बजाय "अधिक जानकारी के लिए स्पर्श करें या एप्लिकेशन को रोकने के लिए" डिफ़ॉल्ट टेक्स्ट जैसे दिखाई नहीं देता है।
यहां प्रासंगिक कोड है:
सेवा:
private final int NOTIFICATION_ID=1;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this,"EDI: Core service Started" , Toast.LENGTH_LONG).show();
startForeground(NOTIFICATION_ID, CoreServiceNotification.getNotification(this, "EDI is online", "Online","Online and running","EDI just started"));
return super.onStartCommand(intent, flags, startId);
}
CoreServiceNotification:
public class CoreServiceNotification {
public static Notification getNotification(Context context,String title,String text,String info,String tickerText){
Notification.Builder notificationBuilder= new Notification.Builder(context);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(text);
notificationBuilder.setContentInfo(info);
notificationBuilder.setTicker(tickerText);
notificationBuilder.setLights(0x00ffff00, 1000, 0);
return notificationBuilder.build();
}
}
परिणाम:
मुझे लगता है कि आप 'बनाने के लिए NotificationManager notificationManager भूलना;' वस्तु तो आप 'notificationManager.notify की तरह जोड़ने के लिए (" 1 ", notificationBuilder); ' –
नहीं, मैं सेवा की StartForeground विधि पर अधिसूचना ऑब्जेक्ट पास कर रहा हूं, यहां विधि देखें [लिंक] (http://developer.android.com/reference/android/app/Service.html) – Allahjane
तो क्या है तुम्हारी समस्या? –