จัดการสถานะเปิดหน้าจอของอุปกรณ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เมื่ออุปกรณ์ที่ใช้ Android ไม่ได้ใช้งาน ระบบจะหรี่แสง
หน้าจอก่อน แล้วจึงปิดหน้าจอ และสุดท้ายจะปิด CPU ซึ่งจะช่วยป้องกันไม่ให้แบตเตอรี่ของอุปกรณ์หมดเร็ว แต่ในบางครั้ง แอปพลิเคชันอาจ
ต้องมีลักษณะการทำงานที่แตกต่างออกไป
- แอป เช่น เกมหรือแอปภาพยนตร์ อาจต้องเปิดหน้าจอไว้
- แอปพลิเคชันอื่นๆ อาจไม่จำเป็นต้องเปิดหน้าจอไว้ แต่ก็อาจ
ต้องใช้ CPU ให้ทำงานต่อไปจนกว่าการดำเนินการที่สำคัญจะเสร็จสิ้น
บทเรียนเหล่านี้อธิบายวิธีทำให้อุปกรณ์ทำงานอยู่เมื่อจำเป็นโดยไม่ทำให้แบตเตอรี่หมด
บทเรียน
- เปิดหน้าจออุปกรณ์ค้างไว้
- ดูวิธีเปิดหน้าจอหรือ CPU ไว้ตามต้องการ พร้อมทั้งลดผลกระทบต่ออายุการใช้งานแบตเตอรี่
- ตั้งเวลาปลุก
- ดูวิธีใช้การปลุกซ้ำเพื่อกำหนดเวลาการทำงานที่เกิดขึ้น
นอกอายุการใช้งานของแอปพลิเคชัน แม้ว่าแอปพลิเคชันจะไม่ได้
ทำงานหรืออุปกรณ์อยู่ในโหมดสลีปก็ตาม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-21 UTC
[[["เข้าใจง่าย","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-08-21 UTC"],[],[],null,["# Manage device awake state\n\nWhen an Android-powered device is left idle, it will first dim, then turn off the\nscreen, and ultimately turn off the CPU. This prevents the device\\\\'s battery\nfrom quickly getting drained. Yet there are times when your application might\nrequire a different behavior:\n\n- Apps such as games or movie apps may need to keep the screen turned on.\n- Other applications may not need the screen to remain on, but they may require the CPU to keep running until a critical operation finishes.\n\nThese lessons describe how to keep a device awake when necessary without\ndraining its battery.\n\nLessons\n-------\n\n**[Keep the device awake](/develop/background-work/background-tasks/scheduling/wakelock)**\n: Learn how to keep the screen or CPU awake as needed, while minimizing the\n impact on battery life.\n\n**[Schedule alarms](/develop/background-work/services/alarms/schedule)**\n: Learn how to use repeating alarms to schedule operations that take place\n outside of the lifetime of the application, even if the application is not\n running or the device is asleep."]]