2012-02-09 4 views
0

나는 음악을 재생하는 MyActivity 및 MyService가 있습니다. 알림창에도 알림이 있지만 버튼을 누르면 MyActivity가 기본 상태로 열립니다 (예 : 음악이 계속 재생되고 있어도 재생 버튼이 눌러지지 않음). 바인딩 작업을 시작하기 전에는 제대로 작동했습니다.Android : 알림 및 Binded 서비스

무엇이 잘못 될 수 있습니까?


편집 : 이것은 내 서비스 안에 내 Noification이

입니다 :

PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, 
      new Intent(getApplicationContext(), SoundRelaxerActivity.class), 
      PendingIntent.FLAG_UPDATE_CURRENT); 
Notification notification = new Notification(); 
notification.tickerText = "Soundrelaxer: "+trackTitle; 
notification.icon = R.drawable.play; 
notification.flags |= Notification.FLAG_ONGOING_EVENT; 
notification.setLatestEventInfo(getApplicationContext(), "SoundRelaxer","Playing: " + trackTitle, pi); 
startForeground(1, notification); 

답변

1

시도 Intent 당신이 당신의 통지에 사용하고있는이 플래그를 추가 :

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 

그런 식으로 당신의 Activi의 새로운 인스턴스 ty는 존재하지 않으면 생성되지 않습니다.

+0

실제로이 유형의 플래그가없는 PendingIntent (Developers Guide Tutorial에서 작동)를 사용하고 있습니다. 아니면 내가 서비스를 시작하려는 의도입니까? 또한 첫 번째 게시물 업데이트를 확인하십시오. –

+0

'PendingIntent'가 아닌'Intent'를'PendingIntent'가 아닙니다. –

+0

감사합니다. 이제 예상대로 작동합니다. –