Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Kullanıcı Android destekli cihazını boşta bıraktığında pilin bitmesini önlemek için cihaz hızlıca askıya alma durumuna geçer. Ancak bazı durumlarda bir uygulamanın CPU'nun askıya alma durumuna geçmesini engellemesi gerekir. Bazı durumlarda, uygulama çalışırken ekranın açık kalması gerekebilir. Diğer durumlarda, uygulamanın ekranı açık tutması gerekmez ancak CPU'nun etkin olması gerekir.
Benimsediğiniz yaklaşım, uygulamanızın ihtiyaçlarına bağlıdır. Ancak genel bir kural olarak, uygulamanızın sistem kaynakları üzerindeki etkisini en aza indirmek için mümkün olan en hafif yaklaşımı kullanmanız gerekir. Bu belge, durumunuza uygun Android teknolojisini seçmenize yardımcı olur.
Doğru teknolojiyi seçme
Cihazınızın uyanık kalmasını sağlamak için en iyi seçenek, uygulamanızın ihtiyaçlarına bağlıdır. Bu bölüm, doğru yaklaşımı seçmenize yardımcı olur.
Uygulamanızın ekranı açık tutması gerekiyor mu?
Evet ise Ekranı açık tutma başlıklı makaleyi inceleyin. İhtiyaçlarınızı karşılayacak özel amaçlı bir API olabilir. Örneğin, telefon görüşmesi kullanıcı arayüzü uyguluyorsanız gerektiğinde ekranı açık tutan Android Telecom Framework'ü kullanabilirsiniz. Durumunuza uygun özel amaçlı bir API yoksa keepScreenOn API'sini kullanabilirsiniz.
Uygulamanız ön plan hizmeti çalıştırıyor ve hizmet çalışırken ekran kapalıyken cihazın uyanık kalmasını mı istiyorsunuz?
Hayır ise cihazı uyanık tutmanız gerekmez. Kullanıcı uygulamayla aktif olarak etkileşimde bulunuyorsa cihaz uyanık kalır. Kullanıcı uygulamanızla etkileşimde bulunmuyorsa ve ön plan hizmeti çalıştırmıyorsanız gerektiğinde cihazın askıya alma moduna girmesine izin vermelisiniz. Kullanıcı uygulamadan uzaktayken bazı işlemlerin yapılmasını sağlamanız gerekiyorsa en iyi seçeneği bulmak için arka plan görevleri dokümanlarına bakın.
Evet ise öncelikle gerçekten ön plan hizmeti kullanmanız gerektiğini doğrulayın. Durumunuza bağlı olarak, ihtiyacınızı karşılamak için ön plan hizmeti yerine kullanabileceğiniz bazı özel amaçlı API'ler olabilir.
Bu hizmetler hakkında bilgiyi Ön Plan Hizmeti dokümanlarında bulabilirsiniz. Örneğin, kullanıcının konumunu izlemeniz gerekiyorsa location ön plan hizmeti yerine coğrafi sınırlama API'sini kullanabilirsiniz.
Ön plan hizmeti çalışırken ve cihaz ekranı kapalıyken cihazın askıya alınması kullanıcı deneyimine zarar verir mi? (Örneğin, bildirimleri güncellemek için ön plan hizmeti kullanıyorsanız cihaz askıya alındığında kötü bir kullanıcı deneyimi yaşanmaz.)
Hayır ise uyanık kalma kilidi kullanmayın. Kullanıcı cihazıyla etkileşime girdiğinde işlem otomatik olarak devam eder ve cihaz askıya alınma durumundan çıkarılır.
Evet ise uyandırma kilidi kullanmanız gerekebilir. Ancak Cihazı uyanık tutan işlemler bölümünde açıklandığı gibi, sizin adınıza uyandırma kilidi bildiren bir API kullanıp kullanmadığınızı veya işlem yapıp yapmadığınızı yine de kontrol etmeniz gerekir.
Cihazı uyanık tutan işlemler
Uygulamanız aşağıdakilerden herhangi birini yapıyorsa kendiniz uyandırma kilidi ayarlamanız gerekmez. Aşağıdaki işlemler ve API'ler, cihazın uyanık kalmasını sağlar.
Ses çalıyorsanız ses sistemi sizin için bir uyandırma kilidi ayarlar ve yönetir. Bunu kendiniz yapmanız gerekmez.
WorkManager,
JobScheduler veya DownloadManager gibi görev planlama API'leri ya da kitaplıkları kullanıyorsanız sistem veya kitaplık, uygulamanızla ilişkilendirilen bir uyanık kalma kilidi edinir.
Belirli cihaz sensörleri uyandırma sensörleridir. Bu sensörlerin raporlayacak verileri olduğunda cihazı uyandırması için SensorManager simgesini kullanabilirsiniz. Bir sensörün uyandırma sensörü olup olmadığını kontrol etmek için Sensor.isWakeUpSensor işlevini çağırın.
Alarm planlarsanız uygulamanız çalışmıyor olsa bile alarm çaldığında cihaz uyanır.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-09-08 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-09-08 UTC."],[],[],null,["When 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\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 wake lock. 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\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- If you [schedule an alarm](/develop/background-work/services/alarms), the device wakes up when the alarm goes off, even if your app is not running.\n\nSee also\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)"]]