저는 이것이 안드로이드 프로그래밍의 큰 멍청한 행동입니다. 나는 푸시 알림 (http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html)을 위해 Vogella 푸시 알림 튜토리얼을 거의 따랐다. 다른 스택 오버플로 관련 질문을 읽었지만 알림을 받으면 의도를 여는 방법에 대해서는 약간 혼란 스럽습니다.푸시 알림을 클릭 한 후 활동 열기 android
예를 들어 알림을 통해 나를 웹 사이트로 안내하려는 경우 어떻게 작동합니까? 내 MessageReceivedActivity 또는 다른 프로젝트/클래스 모두 함께 가야합니까?
덕분에 여기
내가 내 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);
}
} C2DM 또는 클래스가 extentd 기본 리시버에 대한베이스 수신기에서
푸시 알림을 클릭하면 "새 메시지를 받았습니다"메시지 만 표시됩니다. 보류중인 종원에게 의도를 열어 줄 것을 알려줄 필요가 있을까요? – Kevin
신경 쓰지 마라, 코드를 통해 알아 냈다. 1 개의 작은 물건 만 바꾸어야했습니다. 감사! – Kevin