사용자가 Android 지원 기기를 유휴 상태로 두면 배터리가 소모되지 않도록 기기가 빠르게 일시중지 상태로 전환됩니다. 그러나 앱에서 CPU가 일시중지 상태로 전환되지 않도록 해야 하는 경우가 있습니다. 경우에 따라 앱이 작동하는 동안 화면을 켜 두어야 할 수도 있습니다. 다른 경우에는 앱이 화면을 켜진 상태로 유지할 필요가 없지만 CPU가 활성화되어 있어야 합니다.
이를 위해 취하는 접근 방식은 앱의 필요에 따라 다릅니다. 하지만 일반적인 규칙은 앱이 시스템 리소스에 미치는 영향을 최소화할 수 있는 가능한 한 가장 가벼운 방식을 사용하는 것입니다. 이 문서는 상황에 적합한 Android 기술을 선택하는 데 도움이 됩니다.
적합한 기술 선택
기기를 깨어 있게 하는 가장 좋은 방법은 앱의 요구사항에 따라 다릅니다. 이 섹션에서는 적절한 접근 방식을 선택하는 데 도움이 됩니다.
앱에서 화면을 계속 켜야 하나요?
예인 경우 화면 켜기 유지를 참고하세요. 필요한 작업을 실행하는 특수 목적 API가 있을 수 있습니다. 예를 들어 전화 통화 UI를 구현하는 경우 필요한 경우 화면을 켜 두는 Android 텔레콤 프레임워크를 사용할 수 있습니다. 상황에 맞는 특수 목적 API가 없는 경우 keepScreenOn API를 사용할 수 있습니다.
앱에서 포그라운드 서비스를 실행 중이며 서비스가 실행되는 동안 화면이 꺼져 있을 때 기기를 깨어 있어야 하나요?
아니요인 경우 기기를 깨어 있게 유지할 필요가 없습니다. 사용자가 앱과 적극적으로 상호작용하는 경우 기기가 계속 깨어 있습니다. 사용자가 앱과 상호작용하지 않고 포그라운드 서비스를 실행하고 있지 않은 경우 필요한 경우 기기를 일시중지 모드로 전환해야 합니다. 사용자가 앱을 사용하지 않는 동안 일부 작업이 실행되도록 하려면 백그라운드 작업 문서에서 최적의 옵션을 찾아보세요.
예인 경우 먼저 포그라운드 서비스를 실제로 사용해야 하는지 확인합니다. 상황에 따라 포그라운드 서비스 대신 요구사항을 충족하는 데 사용할 수 있는 특수 목적 API가 있을 수 있습니다.
포그라운드 서비스 문서에서 이에 관한 정보를 확인할 수 있습니다. 예를 들어 사용자의 위치를 추적해야 하는 경우 location 포그라운드 서비스 대신 geofencing API를 사용할 수 있습니다.
포그라운드 서비스가 실행 중이고 기기 화면이 꺼져 있는 동안 기기가 정지되면 사용자 환경에 해가 되나요? 예를 들어 포그라운드 서비스를 사용하여 알림을 업데이트하는 경우 기기가 정지되더라도 사용자 환경이 나쁘지 않습니다.
아니요인 경우 wakelock을 사용하지 않습니다. 사용자가 기기와 상호작용하면 작업이 자동으로 재개되어 정지 상태에서 해제됩니다.
예인 경우 wake lock을 사용해야 할 수 있습니다. 하지만 기기를 깨어 있게 하는 작업에서 설명한 대로 이미 API를 사용 중이거나 대신 wake lock을 선언하는 작업을 실행하고 있는지 확인해야 합니다.
기기를 켜진 상태로 유지하는 작업
앱이 다음 중 하나를 실행하는 경우 wake lock을 직접 설정할 필요가 없습니다. 다음 작업과 API는 모두 기기를 깨어 있게 합니다.
오디오를 재생하는 경우 오디오 시스템이 wake lock을 설정하고 관리하므로 개발자가 직접 할 필요가 없습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# Choose the right API to keep the device awake\n\nWhen the user leaves their Android-powered device idle, it quickly goes into the\nsuspend state to avoid draining the battery. However, there are times when an\napp needs to prevent the CPU from going to the suspend state. In some cases, the\napp may need to keep the screen on while it's working. In other cases, the app\ndoesn't need to keep the screen on but still needs the CPU to be active.\n\nThe approach you take depends on the needs of your app. However, a general rule\nis that you should use the most lightweight approach possible, to minimize your\napp's impact on system resources. This document helps you choose the correct\nAndroid technology for your situation.\n| **Note:** You may be familiar with **wake locks**. An app can set a wake lock to keep the device from suspending. However, using a wake lock can quickly drain the device battery. You should only use a wake lock if there's no other option that will do what you need. If you do use a wake lock, you should release it as soon as possible.\n\nChoose the right technology\n---------------------------\n\nThe best option for keeping your device awake depends on your app's needs. This\nsection helps you choose the right approach.\n\n- Does your app need to keep the screen on?\n - If **Yes** , see [Keep the screen on](/develop/background-work/background-tasks/awake/screen-on). There may be a special-purpose API that does what you need; for example, if you're implementing a phone-call UI, you can use the [Android telecom\n framework](/reference/android/telecom/package-summary), which keeps the screen on when needed. If there's no special purpose API for your situation, you can use the `keepScreenOn` API.\n- Is your app running a foreground service, and you need to keep the device awake when screen is off while the service is running?\n - If **No** , you do not need to keep the device awake. If the user is actively interacting with the app, the device will stay awake. If the user is not interacting with your app and you are not running a foreground service, you should let the device go into suspend mode when necessary. If you just need to make sure some work gets done while the user is away from the app, see the [background tasks](/develop/background-work/background-tasks) documentation to find the best option.\n - If **Yes** , first confirm that you actually need to use a foreground service. Depending on your situation, there may be some special-purpose API you can use to accomplish your need instead of a foreground service. You can find information about these [in the Foreground Service\n documentation](/develop/background-work/services/fgs/service-types). For example, if you need to track the user's location, you might be able to use the [geofencing API](/develop/sensors-and-location/location/geofencing) instead of a `location` foreground service.\n- Would it be detrimental to the user experience if the device suspends while the foreground service is running and the device screen is off? (For example, if you're using a foreground service to update notifications, it wouldn't be a bad user experience if the device is suspended.)\n - If **No**, do not use a wakelock. The action resumes automatically once the user engages with their device, which takes it out of suspend.\n - If **Yes** , you might need to [use a wake lock](/develop/background-work/background-tasks/awake/wakelock). However, you should still check to see if you're already using an API or doing an action that declares a wake lock on your behalf, as discussed in [Actions that keep the device awake](#actions-keep).\n\nActions that keep the device awake\n----------------------------------\n\nIf your app is doing any of the following, you don't need to set a wake lock\nyourself. The following actions and APIs all keep the device awake for you.\n\n- If you're playing audio, the audio system sets and manages a wake lock for you; you don't need to do it yourself.\n- If you're using task scheduling APIs or libraries such as [WorkManager](/develop/background-work/background-tasks/persistent), [`JobScheduler`](/reference/android/app/job/JobScheduler), or [`DownloadManager`](/reference/android/app/DownloadManager), the system or library acquires a wake lock that is attributed to your app.\n- If you're using [Media3 ExoPlayer](/media/media3/exoplayer), you can use [`ExoPlayer.setWakeMode()`](/reference/androidx/media3/exoplayer/ExoPlayer#setWakeMode(int)) to have the player set a wake lock for you.\n- Certain device sensors are wake-up sensors; you can use [`SensorManager`](/reference/android/hardware/SensorManager) to have those sensors wake up the device when they have data to report. To check if a sensor is a wake-up sensor, call [`Sensor.isWakeUpSensor`](/reference/android/hardware/Sensor#isWakeUpSensor())).\n\nSee also\n--------\n\n- [Use wake locks](/develop/background-work/background-tasks/awake/wakelock)\n- [Keep the screen on](/develop/background-work/background-tasks/awake/screen-on)"]]