0
내 문제는 하나의 알림 (서버에서 c2dm을 통해 전화로)을 보낼 때 모든 정보가 모두 수신된다는 것입니다.2 개의 알림, 하나만 열 수 있고 다른 하나는 내 활동을 시작하지 않았습니다.
알림이있는 두 개의 아이콘이 있습니다. 내가 그 중 하나를 클릭하면 내 정보 (나는 그것을 클릭 getActivity), 다른 하나는 거짓말처럼 ... 활동을 시작하지 않았다.
내가 PendingIntent에 대해 읽은 것은 활동을 한 번 시작하지만 무엇을해야할지 모르겠다.
마지막 알림뿐만 아니라 모든 알림을받을 필요가 있습니다. 업데이트가 아닙니다.
private void incomingTestp(JSONObject json, Context context) throws JSONException {
Intent intent = new Intent(context, TestpViewActivity.class);
Testp testp = Testp.fromJSON(json);
TestpServiceUtil.save(testp);
intent.putExtra("testpId", testp.getTestpId());
sendNotification("New Testp", "update", intent, testp.getTestpId(), context);
}
private void incomingTestr(JSONObject json, Context context) throws JSONException {
Intent intent = new Intent(context, TestrViewActivity.class);
Testr Testr = Testr.fromJSON(json);
TestrServiceUtil.save(testr);
intent.putExtra("testrId", testr.getTestrId());
sendNotification("New Testr", "update", intent, report.getTestrId(), context);
}
private void sendNotification(String title, String description, Intent intent, long id, Context context) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, title, System.currentTimeMillis());
intent.putExtra("force", true);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(context.getApplicationContext(), title, description, PendingIntent.getActivity(context, requestCode++, intent, Intent.FLAG_ACTIVITY_NEW_TASK));
notification.vibrate = new long[] { 0, 200, 100 };
//notification.defaults |= Notification.DEFAULT_SOUND;
notificationManager.notify("Test", (int) id, notification);
}
나는이 방법을 어떻게 부르는 지 알기 위해 좀 더 많은 정보를 제공합니다.
감사합니다.하지만 두 번 같은 알림이 표시됩니다. 현재 업데이트 중 일부 플래그를 사용해야합니다 ... – nayden
이제 마지막 알림을 시작할 때마다. 내가 무엇을 할 수 있을지? – nayden
알림에 대해 동일한 ID를 사용하면 업데이트가됩니다 ... –