안드로이드 개발 질문/답변
(글 수 45,052)
제가 액티비티를 상속받은 A라는 클래스에 알람매니저를 setRepeating으로 등록해서 30초마다 반복하도록 해놨습니다.
그래서 30초마다 PendingIntent로 설정해놓은 서비스를 상속받은 클래스가 실행되는데요...
문제는
30초마다 실행되는 서비스내에서 어떤 조건을 만족시키면
A클래스에서 setRepeating으로 등록해 놓은 알람을 cancel시켜야되는것입니다 ㅠ
이거 어떻게 하는지 아시는 분 계시면 제발 좀 도와주세요 ㅠㅠㅠ
2012.01.08 11:05:50
댓글 감사합니다 ^^
그런데 봐도 잘 이해가 안가서요 ㅠ
Intent intent2=new Intent(A.this,Back2.class);
final PendingIntent sender2=PendingIntent.getService(Push.this, 0, intent2, 1234);
am2.setRepeating(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis()-600000, 30*1000, sender2);
위에 코드가 A클래스에서 등록시킨 알람입니다
30초마다 불려질 Back2라는 서비스를 상속받은 클래스에서 저기서 생성시킨 am2를 어떻게 접근하는지 잘 모르겠습니다 ㅠ
그러니까
서비스에서 cancel( ?? )
??에 뭘 넣어야될지 모르겠습니다 ...
조언 좀 부탁드립니다 ㅠㅠㅠ
2012.01.08 21:13:38
아 ...
그럼 Back2에서도
Intent intent2=new Intent(this,Back2.class);
final PendingIntent sender2=PendingIntent.getService(this, 0, intent2, 1234);
am2=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
코드에 ↑ 이걸 똑같이 한번 더 넣어주는건가요 ??
... 이해가 안가요 ㅠㅠㅠ
sender2는 A클래스에서 생성한건데 Back2에서 어떻게 불러와서 쓰나요 ??
위에처럼 똑같이 한번 더 넣어준다고 해서 A클래스에서 생성한 sender2랑 같은 PendingIntent가 생성되는건가요 ?? ㅠㅠㅠ




http://developer.android.com/reference/android/app/AlarmManager.html
cancel 보시면 될 듯 합니다.