GCM 서버에서 메시지 왔을때 푸쉬

 

NotificationManager notificationManager = (NotificationManager)
     getSystemService(NOTIFICATION_SERVICE);
  Notification notification = new Notification(R.drawable.ic_launcher,
    "새 메시지 도착!", System.currentTimeMillis());


   notification.flags |= Notification.FLAG_AUTO_CANCEL;

  Intent intent = new Intent(this, MainActivity.class);
  PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
  notification.setLatestEventInfo(this, "새 메시지 도착",
    "새 메시지가 도착했습니다", activity);
  notification.number += 1;
  notificationManager.notify(0, notification);

 

이런식으로 처리하는데요.. 눌렀을때 이동하는 MainActivty 즉 자신을 다시 시작하는데요 MainActivity 실행중에

 

이때 다시 메시지가 오게되면 앱종료시 NotificationManager  가 와있는 현상을 없애고 싶은데.. 

 

어떤식으로  수정해야 할까요??