2012-02-02 5 views
0

클릭하면 앱이 백그라운드에서 전면으로 이동합니다. 다음 코드를 사용하고 있습니다 :앱을 클릭하면 알림이 표시됩니다.

NotificationManager noma = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
PendingIntent pen = PendingIntent.getActivity(Timer.this, 0, intent, 0); 
intent.putExtra("key", "trigerred"); 
String body = "This is a message"; 
String title = "This is title"; 
Notification no = new Notification(R.drawable.ic_launcher, body, System.currentTimeMillis()); 
no.defaults = Notification.DEFAULT_ALL; 
no.setLatestEventInfo(this, title, body, pen); 
noma.notify(uniqueID, no); 

새로운 의도를 만드는 알림을 클릭했지만 맨 앞에 만든 의도를 원하는 경우. 내가 어떻게 할 수 있니?

+0

가능한 중복 시도 [알림을 클릭 - 응용 프로그램으로 보내기] (http://stackoverflow.com/questions/3172966/click-notification-send-to-application) –

+0

우편 번호 곳 당신은 당신의 의도 객체를 얻습니다. – Natali

+0

http://stackoverflow.com/questions/6575730/notification-to-restore-a-task-rather-than-a-specific-activity –

답변

1

getActivity에 전달한 의도로 FLAG_ACTIVITY_SINGLE_TOP 플래그를 설정해야합니다. 알림을 클릭하면 실행 준비가 완료된 모든 활동으로 돌아갑니다.

다른 실행 플래그의 목록은 here을 참조하십시오.

+0

에 대한 답변보기이 방법은 효과가 없습니다. 예를 들어 주시겠습니까? – afb

+0

죄송합니다. 문서를 다시 읽으십시오. FLAG_ACTIVITY_NEW_TASK 플래그를 설정해야한다고 생각합니다. 이 플래그는 활동을 새 태스크로 시작하지만,이 활동이 모두 준비된 태스크가 존재하면 대신 포어 그라운드로 가져옵니다. – mcnicholls

0

PendingIntent pen = PendingIntent.getActivity(Timer.this, 0, intent,Intent.FLAG_ACTIVITY_TASK_ON_HOME); 
관련 문제