안드로이드의 AlarmManager 자바 독 상태알람 관리기의 웨이크 잠금에 AlarmService을 보여 안드로이드와 함께 제공되는 API 데모에 서비스를
When an alarm goes off, the Intent that had been registered for it is broadcast by the system,
AlarmService
(패키지 com.example.android.apis.app가) 있습니다를 시작할 때 용도. 그것에서
우리는 (명확성을 위해 편집) 다음 한 :
이PendingIntent mAlarmSender = PendingIntent.getService(AlarmService.this,
0, new Intent(AlarmService.this, AlarmService_Service.class), 0);
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 30*1000, mAlarmSender);
그래서이 예에서이 PendingIntent mAlarmSender = PendingIntent.getBroadcast(...);
을하지 않는 대신 그것은 자바 독가 암시 적이없는 getService
않습니다.
이유는 내가 이것에 대해 묻는 이유는 CPU 깨우기 잠금의 영향 때문입니다. Javadoc에 따르면 Broadcast 수신기의 onReceive()
이 반환되면 AlarmManger의 wake lock이 해제됩니다.
예에서와 같이 Alarm을 사용하면 잠자기시 함 수가 의미하는 바가 무엇입니까? Javadoc은 이것을 다루지 않는 것 같습니다. 아무거나는 경보를 설치할 경우 당신이 방송 기술을 사용해야한다는 것을 암시하는 것처럼 보인다.
완벽한 답변 - 위대한 첨부. 많은 감사 – Tim
또한 .. WakefulIntentService를 취소하는 가장 좋은 방법은 무엇입니까? – Tim
@Tim : "WakefulIntentService 취소"가 무슨 뜻인지 잘 모르겠습니다. 'AlarmManager'에서'cancel()'을 통해 알람을 취소 할 수 있습니다. – CommonsWare