में चल रहा है तो अलर्ट बॉक्स में पुश अधिसूचना प्रदर्शित करें, मैं अपने एंड्रॉइड ऐप में पुश अधिसूचना कर रहा हूं जो जीसीएम द्वारा ट्रिगर किया गया है। यदि एप नहीं चल रहा है, तो ऐप अधिसूचना प्रदर्शित करना चाहता है, यदि ऐप नहीं चल रहा है, तो अग्रभूमि में नहीं है, बस स्टेटस बार अधिसूचना प्रदर्शित करें, आप कैसे निर्धारित करते हैं कि ऐप चल रहा है और अग्रभूमि में है? इस तरह की अधिसूचना दिखाना संभव है। अब मैं इस स्थिति का उपयोग शो स्टेटस बार पुश अधिसूचनाजब एप फोरग्राउंड
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, BottomActivity.class);
// set intent so it does not start a new activity
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;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
प्रयास करें अगर यह एक नई परियोजना आप C2DM की बजाय GCM का उपयोग करना चाहिए के रूप में यह पदावनत है और गूगल कहते हैं कि "C2DM कोई भी नया उपयोगकर्ता को स्वीकार करेंगे, और यह कोई नया अनुदान देगा कोटा " – NickT
ठीक है धन्यवाद, मैं जीसीएम का उपयोग करूंगा और अपने प्रश्न को संपादित करने जा रहा हूं –
@ जिथू मुझे अपने ऐप्स में से एक में भी ऐसा करने की ज़रूरत है, क्या आपको यहां एक उचित समाधान और दिमाग पोस्ट करना है, यह एक बड़ी मदद होगी धन्यवाद। –