मैं अपने एंड्रॉइड एप्लिकेशन को बनाने के लिए कॉर्डोवा का उपयोग कर रहा हूं। चूंकि एंड्रॉइड सेवा मारता है, इसलिए मैं सेवा मारने से बचने के लिए अधिसूचना के साथ बाध्यकारी सेवा कर रहा हूं।कॉर्डोवा - पृष्ठभूमि चल रही सेवा को सूचित करें
यहाँ मेरी विधि मैं कैसे अधिसूचना
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
context = this.getApplicationContext();
notifyService();
return START_NOT_STICKY;
}
private void notifyService() {
String package_name = this.getApplication().getPackageName();
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Bitmap icon = BitmapFactory.decodeResource(getResources(),
this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi", package_name));
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Smart Home")
.setContentText("Smart Home running in background")
.setSmallIcon(this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi", package_name))
.setContentIntent(pendingIntent)
.setOngoing(true)
.build();
startForeground(notificationId, notification);
}
साथ सेवा बाँध यहाँ उत्पादन
अधिसूचना उत्पन्न होता है, लेकिन जैसा कि मैंने सेट अधिसूचना शीर्षक नहीं है। साथ ही, जब मैं इस अधिसूचना पर क्लिक करता हूं, तो यह ऐप जानकारी गतिविधि में जा रहा है। लेकिन मैं अपनी मुख्य गतिविधि में जाना चाहता हूं।
क्या किसी को भी इस समस्या का सामना करना पड़ा है? या मेरे कोड को कॉर्डोवा के लिए कोई बदलाव चाहिए?
क्या आप पृष्ठभूमि में सेवा के रूप में कॉर्डोवा अधिसूचना ऐप चाहते हैं? क्या यह आपका सवाल है? – Gandhi
@ गंधी मैं अपनी प्लगइन से एक सेवा शुरू कर रहा हूं। और मैं नहीं चाहता कि एंड्रॉइड इसे मार डाले। तो मैं एक अग्रभूमि अधिसूचना का उपयोग कर रहा हूँ। मैं अधिसूचना के साथ इसे सूचित कर सकता हूं लेकिन उत्पन्न अधिसूचना मेरी अधिसूचना –
शर्मिंदा नहीं है क्या आपने इस प्लगइन को देखा - https://github.com/Red-Folder/bgs-core/wiki/Build-your-own-Background- सेवा – Gandhi