불필요한 wakeup
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
wakeup은 개발자가 지정된 시간에 기기의 절전 모드를 해제하도록 알람을 설정할 수 있는 AlarmManager
API의 메커니즘입니다. 앱은 AlarmManager
의 set()
메서드 중 하나를 RTC_WAKEUP
또는 ELAPSED_REALTIME_WAKEUP
플래그와 함께 호출하여 wakeup 알람을 설정합니다. wakeup 알람이 트리거되면 기기는 저전력 모드에서 나와 알람의 onReceive()
또는 onAlarm()
메서드를 실행하는 동안 부분적인 wake lock 상태를 유지합니다. wakeup 알람이 불필요하게 트리거되면 기기의 배터리가 소모될 수 있습니다.
앱 품질을 개선하기 위해 Android에서는 앱에 불필요한 wakeup 알람이 발생하는지 자동으로 모니터링하고 Android vitals에 정보를 표시합니다. 데이터가 수집되는 방법에 관한 자세한 내용은 Play Console 문서를 참고하세요.
앱에서 불필요하게 기기의 절전 모드를 해제하는 경우 이 페이지의 안내를 사용하여 문제를 진단하고 해결할 수 있습니다.
문제 해결
이전 AlarmManager
Android 플랫폼의 초기 버전에 도입되었지만 시간이 지나면서
이전에 필요했던
AlarmManager
이(가) 현재
더 나은 결과를 얻기 위해
WorkManager:
이 섹션에는 wakeup 알람을 줄이기 위한 도움말이 포함되어 있지만 장기적으로 권장사항 섹션에 있는 권장사항을 따르도록 앱을 이전하는 것이 좋습니다.
wakeup 알람을 예약한 앱의 위치를 식별하고 해당하는 알람이 트리거되는 빈도를 줄이세요. 다음은 몇 가지 팁입니다.
RTC_WAKEUP
또는 ELAPSED_REALTIME_WAKEUP
플래그 중 하나를 포함하는 AlarmManager
의 다양한 set()
메서드 호출을 찾습니다.
알람이 설정된 소스의 위치를 쉽게 식별할 수 있도록 패키지, 클래스 또는 메서드 이름을 알람의 태그 이름에 포함하는 것이 좋습니다. 다음은 몇 가지 추가적인 도움말입니다.
- 이름에서 이메일 주소와 같은 개인 식별 정보(PII)를 제외하세요. 그러지 않으면 기기가 알람 이름 대신
_UNKNOWN
을 로깅합니다.
- Proguard로 난독화되었을 수 있으므로 프로그래매틱 방식(예:
getName()
호출)으로 클래스 또는 메서드 이름을 가져오면 안 됩니다. 대신 하드 코딩된 문자열을 사용하세요.
- 알람 태그에 카운터 또는 고유 식별자를 추가하지 마세요. 알람 모두에는 고유 식별자가 있으므로 시스템에서 이러한 방식으로 설정된 알람을 집계할 수 없습니다.
문제를 해결한 후 다음 adb 명령어를 실행하여 wakeup 알람이 예상대로 작동하는지 확인하세요.
adb shell dumpsys alarm
이 명령어는 기기의 알람 시스템 서비스 상태에 관한 정보를 제공합니다. 자세한 내용은 dumpsys를 참고하세요.
권장사항
앱에서 알림을 게시하거나 사용자에게 알림을 보내는 등 사용자에게 표시되는 작업을 실행해야 하는 경우에만 wakeup 알람을 사용하세요. AlarmManager 권장사항 목록은 반복 알람 예약을 참고하세요.
AlarmManager
를 사용하여 백그라운드 작업, 특히 반복되거나 네트워크 백그라운드에서 실행되는 작업을 예약하면 안 됩니다. 다음과 같은 이점이 있으므로 백그라운드 작업을 예약하려면 WorkManager를 사용하세요.
- 일괄 처리 - 작업이 결합되므로 배터리 소모가 줄어듭니다.
- 지속성 - 기기가 재부팅되는 경우 재부팅이 완료된 후 예약된 WorkManager 작업이 실행됩니다.
- 기준 - 기기가 충전 중이거나 Wi-Fi가 사용 가능한지 여부와 같은 조건에 따라 작업을 실행할 수 있습니다.
자세한 내용은 백그라운드 처리 가이드를 참고하세요.
AlarmManager
를 사용하여 앱이 실행되는 동안에만 유효한 타이밍 작업(사용자가 앱을 종료할 때 취소되어야 하는 타이밍 작업)을 예약하면 안 됩니다. 이러한 상황에서는 더 사용하기 쉽고 훨씬 효율적인 Handler
클래스를 사용하세요.
추천 서비스
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Excessive wakeups\n\nWakeups are a mechanism in the\n[`AlarmManager`](/reference/android/app/AlarmManager) API that\nlets developers set an alarm to wake up a device at a specified time. Your app\nsets a wakeup alarm by calling one of the `set()` methods in\n[`AlarmManager`](/reference/android/app/AlarmManager) with\neither the\n[`RTC_WAKEUP`](/reference/android/app/AlarmManager#RTC_WAKEUP)\nor\n[`ELAPSED_REALTIME_WAKEUP`](/reference/android/app/AlarmManager#ELAPSED_REALTIME_WAKEUP)\nflag. When a wakeup alarm is triggered, the device comes out of low-power mode\nand holds a [partial wake lock](/topic/performance/vitals/wakelock) while executing the alarm's\n[`onReceive()`](/reference/android/content/BroadcastReceiver#onReceive(android.content.Context,%20android.content.Intent))\nor\n[`onAlarm()`](/reference/android/app/AlarmManager.OnAlarmListener#onAlarm())\nmethod. If wakeup alarms are triggered excessively, they can drain a device's\nbattery.\n\nTo help you improve app quality, Android automatically monitors apps for\nexcessive wakeup alarms and displays the information in Android vitals. For\ninformation on how the data is collected, see [Play Console\ndocs](https://support.google.com/googleplay/android-developer/answer/7385505).\n\nIf your app is waking up the device excessively, you can use the guidance in\nthis page to diagnose and fix the problem.\n\nFix the problem\n---------------\n\nThe [`AlarmManager`](/reference/android/app/AlarmManager) was\nintroduced in early versions of the Android platform, but over time, many use\ncases that previously required\n[`AlarmManager`](/reference/android/app/AlarmManager) are now\nbetter served by newer features like\n[WorkManager](/topic/libraries/architecture/workmanager).\nThis section contains tips for reducing wake up alarms, but in the long term,\nconsider migrating your app to follow the recommendations in the [best\npractices](#best_practices) section.\n\nIdentify the places in your app where you schedule wakeup alarms and reduce\nthe frequency that those alarms are triggered. Here are some tips:\n\n- Look for calls to the various\n [`set()`](/reference/android/app/AlarmManager#set(int,%20long,%20java.lang.String,%20android.app.AlarmManager.OnAlarmListener,%20android.os.Handler))\n methods in\n [`AlarmManager`](/reference/android/app/AlarmManager) that\n include either the\n [`RTC_WAKEUP`](/reference/android/app/AlarmManager#RTC_WAKEUP)\n or\n [`ELAPSED_REALTIME_WAKEUP`](/reference/android/app/AlarmManager#ELAPSED_REALTIME_WAKEUP)\n flag.\n\n- We recommend including your package, class, or method name in your alarm's tag\n name so that you can easily identify the location in your source where the\n alarm was set. Here are some additional tips:\n\n - Leave out any personally identifying information (PII) in the name, such as an email address. Otherwise, the device logs `_UNKNOWN` instead of the alarm name.\n - Don't get the class or method name programmatically, for example by calling [`getName()`](/reference/java/lang/Class#getName()), because it could get obfuscated by Proguard. Instead use a hard-coded string.\n - Don't add a counter or unique identifiers to alarm tags. The system will not be able to aggregate alarms that are set that way because they all have unique identifiers.\n\nAfter fixing the problem, verify that your wakeup alarms are working as\nexpected by running the following [ADB](/studio/command-line/adb)\ncommand: \n\n adb shell dumpsys alarm\n\nThis command provides information about the status of the alarm system service\non the device. For more information, see\n[dumpsys](https://source.android.com/devices/tech/debug/dumpsys).\n\nBest practices\n--------------\n\nUse wakeup alarms only if your app needs to perform a user facing operation\n(such as posting a notification or alerting the user). For a list of\nAlarmManager best practices, see [Scheduling\nAlarms](/training/scheduling/alarms).\n\nDon't use\n[`AlarmManager`](/reference/android/app/AlarmManager) to\nschedule background tasks, especially repeating or network background tasks. Use\n[WorkManager](/topic/libraries/architecture/workmanager)\nto schedule background tasks because it offers the following benefits:\n\n- batching - jobs are combined so that battery consumption is reduced\n- persistence - if the device is rebooted, scheduled WorkManager jobs run after the reboot finishes\n- criteria - jobs can run based on conditions, such as whether or not the device is charging or WiFi is available\n\nFor more information, see [Guide to background processing](/guide/background).\n\nDon't use [`AlarmManager`](/reference/android/app/AlarmManager)\nto schedule timing operations that are valid only while the app is running (in\nother words, the timing operation should be canceled when the user exits the\napp). In those situations, use the\n[`Handler`](/reference/android/os/Handler) class because it is\neasier to use and much more efficient.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Stuck partial wake locks](/topic/performance/vitals/wakelock)\n- [ANRs](/topic/performance/vitals/anr)"]]