मैं अपने एंड्रॉइड ऐप पर एफसीएम का उपयोग करके एक अधिसूचना दिखा रहा हूं। एक मुद्दे को छोड़कर सब कुछ उम्मीद के मुताबिक काम कर रहा है।
जब उपयोगकर्ता अधिसूचना पर क्लिक करता है, तो मुझे अपने ऐप की सभी पृष्ठभूमि और अग्रभूमि गतिविधियों को बंद करने और अधिसूचना में निर्दिष्ट इरादे को खोलने की आवश्यकता होती है।
मैं यह कैसे कर सकता हूं?
मैं इस तरह लंबित इरादे का उपयोग कर रहा हूँ
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
final PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mContext,
0,
intent,
PendingIntent.FLAG_CANCEL_CURRENT
);
2 जवाब
आप सभी स्टैक को साफ़ करने के लिए 2 फ़्लैग का उपयोग कर सकते हैं
intentToLaunch.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intentToLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ये कोशिश करें,
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
Intent notificationIntent = new Intent(context, HomeActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
संबंधित सवाल
नए सवाल
android
एंड्रॉइड Google का मोबाइल ऑपरेटिंग सिस्टम है, जिसका उपयोग प्रोग्रामिंग या डिजिटल डिवाइस (स्मार्टफोन, टैबलेट, ऑटोमोबाइल्स, टीवी, वियर, ग्लास, IoT) को विकसित करने के लिए किया जाता है। एंड्रॉइड से संबंधित विषयों के लिए, एंड्रॉइड-विशिष्ट टैग जैसे कि एंड्रॉइड-इरादे, एंड्रॉइड-गतिविधि, एंड्रॉइड-एडॉप्टर आदि का उपयोग करें। विकास या प्रोग्रामिंग के अलावा अन्य प्रश्नों के लिए, लेकिन एंड्रॉइड फ्रेमवर्क से संबंधित हैं, इस लिंक का उपयोग करें: https: // android.stackexchange.com।