마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

알람을 서비스에서 취소할 때..

0 추천
알람매니저를 액티비티에서 만들었어요.

 

TestActivity.class

PendingIntent pender = PendingIntent.getService(TestActivity.this, num, intent, 0);
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 60 * 60 * 1000, pender);

 

그런데 알람매니저 취소는 서비스에서 하거든요.

서비스에서 취소할 때 PendingInent에 getservice 주체는 누구를 적어야해요?

1번: 알람매니저에서 등록한 TestActity.this

PendingIntent pender = PendingIntent.getService(TestActivity.this, num, intent, 0);

 

2번 : 서비스 객체?

PendingIntent pender = PendingIntent.getService(AlarmService.this, num, intent, 0);

 

누구를 적어야하는지 모르겠어요..

좀 가르켜주세요 ㅠㅜ..
초봉초봉 (3,480 포인트) 님이 2015년 2월 17일 질문

1개의 답변

0 추천
1번이죠 등록할때 만들었던 PendingIntent 를 똑같이 만들어서 취소하면 됩니다.
Gradler (109,780 포인트) 님이 2015년 2월 17일 답변
그런데 서비스에서 TestAcitivity.this 하면 에러가 나요.
cannot be resolved to a variable 라고요...

이럴때는 그럼 어떻게 등록해야하나요?
...