การล็อกการตื่นบางส่วนเป็นกลไกใน PowerManager API ที่ช่วยให้ผู้พัฒนาแอปสามารถทำให้ CPU ทำงานต่อไปได้หลังจากที่จอแสดงผลของอุปกรณ์ปิดลง (ไม่ว่าจะเกิดจากระบบหมดเวลาหรือผู้ใช้กดปุ่มเปิด/ปิด) แอปของคุณจะรับการล็อกการปลุกบางส่วนโดยการเรียกใช้ acquire() พร้อม Flag PARTIAL_WAKE_LOCK หรือใช้ API อื่นๆ ที่ได้รับสิทธิ์การล็อกการปลุก
การใช้การล็อกการตื่นบางส่วนมากเกินไปจะทำให้แบตเตอรี่ของอุปกรณ์หมดเร็ว เนื่องจากจะป้องกันไม่ให้อุปกรณ์เข้าสู่สถานะพลังงานต่ำ ควรใช้การล็อกการตื่นบางส่วนเมื่อจำเป็นเท่านั้นและปล่อยออกทันทีที่ไม่จำเป็นแล้ว
คุณไม่ควรใช้การล็อกที่ปลุกอุปกรณ์ไว้หากมีวิธีอื่น เนื่องจากอาจทำให้แบตเตอรี่ของอุปกรณ์หมดเร็ว เอกสารประกอบเกี่ยวกับเลือก API ที่เหมาะสมเพื่อทำให้อุปกรณ์ทำงานต่อไปจะช่วยคุณค้นหาโซลูชันที่ดีที่สุดสำหรับแอป
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Excessive partial wake locks (beta)\n\nPartial wake locks are a mechanism in the [`PowerManager`](/reference/android/os/PowerManager) API that lets\ndevelopers keep the CPU running after a device's display turns off (whether due\nto system timeout or the user pressing the power button). Your app acquires a\npartial wake lock by calling [`acquire()`](/reference/android/os/PowerManager.WakeLock#acquire()) with the [`PARTIAL_WAKE_LOCK`](/reference/android/os/PowerManager#PARTIAL_WAKE_LOCK)\nflag, or by using [other APIs that acquire wake locks](/develop/background-work/background-tasks/awake/wakelock/identify-wls).\nExcessive use of partial wake locks drains the device's battery because it\nprevents the device from entering lower power states. Partial wake locks should\nbe used only when necessary and released as soon as no longer needed.\n\nIf your app uses partial wake locks excessively, you can use the guidance in\nthis page to diagnose and fix the problem.\n\nYour feedback is a crucial part of improving our documentation. Please give us\nyour feedback using the following link:\n\n\n[Give feedback](https://docs.google.com/forms/d/e/1FAIpQLScYkStao0zVsmPay22DGqYEMJSf2Rk3SE3LnPc1lcmLjN1AiQ/viewform?usp=dialog)\n\nDetect the problem\n------------------\n\nAndroid vitals can help you find out when your app's use of partial wake locks\nis excessive.\n\n### Android vitals\n\nAndroid vitals can help improve your app's performance by [alerting you via the\nPlay Console](https://support.google.com/googleplay/android-developer/answer/9844486?) when your app's use of partial wake locks is\nexcessive.\n| **Note:** Tracking of excessive partial wake locks is **currently in beta**. The threshold numbers, relevant app states, and exceptions for behavior that has end-user benefit, are all subject to change. The beta metric does not currently make your app less discoverable on Google Play. Once the metric is out of beta, excessive partial wake lock use may impact app discoverability on Play.\n\nAndroid vitals reports partial wake lock use as **excessive** when **all of the\npartial wake locks**, added together, run for 3 or more hours in 24-hour\nperiod.\n\nAndroid vitals tracks time only if the wake lock is held when the app **is in\nthe background** and **does not have a foreground service**.\n\nAndroid vitals gives some exemptions to partial wake lock usage in scenarios\nwhere there is a clear user benefit of the partial wake lock, and there's no\nbetter way to achieve that result without the partial wake lock. In those cases,\nAndroid vitals might not count the partial wake lock time against the 3-hour\nlimit. For example, if an app is playing audio for the user, there's a clear\nbenefit to keeping the device awake and there's no way to play the audio without\nkeeping the device awake. In that case, the partial wake lock time is not\ncounted against the Android vitals.\n\nIf excessive partial wake locks occur in more than 5% of app sessions across all\ndevices in a 28-day period, it can affect your app's visibility on Play once the\nmetric is out of beta.\n\nOnce you're aware that your app has excessive partial wake locks,\nyour next step is to address the issue.\n\nFix the problem\n---------------\n\nBecause wake locks can drain the device battery, you shouldn't use wake\nlocks if there's an alternative. The\n[Choose the right API to keep the device awake](/develop/background-work/background-tasks/awake)\ndocumentation can help you find the best solution for your app.\n\nIf you do need to use a wake lock, [follow wake lock best practices](/develop/background-work/background-tasks/awake/wakelock/best-practices)\nto make sure your wake locks don't hurt device efficiency. In particular,\nmake sure every device you acquire is released, and release the lock as quickly\nas possible.\n\nAfter fixing the problem in code, you can verify your fixes by using [local\nwake lock debugging tools](/develop/background-work/background-tasks/awake/wakelock/debug-locally).\n\nSee also\n--------\n\n- [Stuck partial wake locks](/topic/performance/vitals/excessive-wakelock)\n- [Wake lock documentation](/develop/background-work/background-tasks/awake/wakelock)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Frozen frames](/topic/performance/vitals/render#frozen-frames)\n- [Run benchmarks in Continuous Integration](/topic/performance/benchmarking/benchmarking-in-ci)\n- [Create and measure Baseline Profiles without Macrobenchmark](/topic/performance/baselineprofiles/manually-create-measure)"]]