मेरे पास एक सेवा चल रही है जो अधिसूचना बार में अधिसूचना अद्यतन करती है जब यह एक संदेश प्राप्त करता है जिसमें कहा जाता है कि इसे बदला जाना है।एंड्रॉइड - java.lang.IllegalArgumentException: contentIntent अधिसूचना के कारण त्रुटि की आवश्यकता है?
चर सेटअप
int icon = R.drawable.notification;
CharSequence tickerText = "Test";
long when = System.currentTimeMillis();
PendingIntent contentIntent;
Notification notification = new Notification(icon, tickerText, when);
NotificationManager mNotificationManager;
NotificationManager:
हालांकि मैं कभी कभी जब अधिसूचना
java.lang.IllegalArgumentException: contentIntent required
यहाँ अद्यतन किया जाना है निम्नलिखित त्रुटि मिलती है मेरी कोड है सृष्टि
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
अधिसूचना निर्माण
Intent notificationIntent = new Intent(this, TestsApp.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.icon = R.drawable.notification3;
notification.setLatestEventInfo(this, "Registering", "Test", contentIntent);
mNotificationManager.notify(1, notification);
अधिसूचना का अद्यतन
notification.icon = R.drawable.notification2;
notification.setLatestEventInfo(getApplicationContext(), "Registered", "Test", contentIntent);
mNotificationManager.notify(1, notification);
तो कुछ रेखा के साथ कहीं न कहीं मेरे contentIntent हो रहा है, क्या यह सही हो सकता है?
यह सदस्य सेवा चर के रूप में मेरी सेवा कक्षा के शीर्ष पर घोषित किया गया है और उपरोक्त दिखाए गए कोड में कहीं और नहीं उपयोग किया जाता है, तो यह शून्य पर रीसेट हो सकता है?
Android के सभी संस्करणों में यह आवश्यकता होती है। मेरे पास ऐसा मामला था जो किंडल फायर को छोड़कर सब कुछ ठीक काम कर रहा था। –
क्या आप जानते हैं कि अगर मैं अधिसूचना पर क्लिक करने के लिए कोई इरादा नहीं चाहता हूं तो मैं क्या करूँ? मैं बस वहां रहना चाहता हूं जबकि सिस्टम कुछ कर रहा है और यह स्वयं ही जाएगा। मेरे मामले के लिए –
, सेवा से notificationBar दिखा रहा है, कि mBuilder.setContentIntent (PendingIntent.getActivity (यह, 0, नई आशय(), 0)) हो सकता है; – toantran