पर क्लिक करने के बाद गतिविधि खोलना मैं एंड्रॉइड प्रोग्रामिंग के लिए एक बड़ा नोब हूं इसलिए क्षमा करें यदि यह एक आसान काम है। मैंने पुश अधिसूचनाओं के लिए वोगेला पुश अधिसूचना ट्यूटोरियल का बहुत पालन किया (http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html)। मैंने कुछ अन्य स्टैक ओवरफ़्लो प्रश्न पढ़े हैं लेकिन मुझे अधिसूचना मिलने के बाद एक इरादा खोलने के बारे में थोड़ा उलझन में है।पुश अधिसूचना एंड्रॉइड
उदाहरण के लिए, अगर मैं सिर्फ एक वेबसाइट पर जाने के लिए अधिसूचना चाहता था, तो यह कैसे काम करेगा? क्या इसे मेरे संदेश रिसीव एक्टिविटी या किसी अन्य प्रोजेक्ट/क्लास के साथ मिलकर जाना होगा?
धन्यवाद
यहाँ कोड मैं अपने C2DMMessageReceiver
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w("C2DM", "Message Receiver called");
if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
Log.w("C2DM", "Received message");
final String payload = intent.getStringExtra("payload");
Log.d("C2DM", "dmControl: payload = " + payload);
// TODO Send this to my application server to get the real data
// Lets make something visible to show that we received the message
createNotification(context, payload);
}
}
public void createNotification(Context context, String payload) {
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,
"Message received", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//adding LED lights to notification
notification.defaults |= Notification.DEFAULT_LIGHTS;
Intent intent = new Intent(context, MessageReceivedActivity.class);
intent.putExtra("payload", payload);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
notification.setLatestEventInfo(context, "Message",
"New message received", pendingIntent);
notificationManager.notify(0, notification);
}
}
जब मैं ऐसा करता हूं, तो मेरी पुश अधिसूचना पर क्लिक करने के बाद, मुझे केवल "नया संदेश प्राप्त हुआ" संदेश दिखाई देता है। हो सकता है कि इरादे को खोलने के लिए लंबित इंंटेंट को कुछ बताने की ज़रूरत है? – Kevin
कभी नहीं, इसे अपने कोड के माध्यम से समझ लिया। केवल 1 छोटी चीज को बदलना पड़ा। धन्यवाद! – Kevin