ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
เครื่องมือติดตามลักษณะการทํางานของแอปในเบื้องหลัง
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android 13 เปิดตัวแนวคิดเครื่องมือติดตามการใช้พลังงาน ซึ่งเป็นกระบวนการที่ตรวจสอบการใช้แบตเตอรี่ในเบื้องหน้าหรือเบื้องหลังของแอปเพื่อพิจารณาว่าแอปละเมิดนโยบายบางอย่างหรือไม่
Android 13 มีเครื่องมือติดตามการสิ้นเปลืองพลังงาน 2 รายการ ได้แก่ เครื่องมือติดตามบริการที่ทำงานอยู่เบื้องหน้าและเครื่องมือติดตามการใช้งานแบตเตอรี่ในเบื้องหลัง เราขอแนะนำให้ใช้เครื่องมือติดตามเหล่านี้เพื่อตรวจสอบและแจ้งเตือนผู้ใช้เกี่ยวกับการใช้งานแบตเตอรี่มากเกินไป แทนที่จะใช้กลไกของคุณเองเพื่อระบุว่าแอปละเมิดแบตเตอรี่
เครื่องมือติดตามบริการที่ทำงานอยู่เบื้องหน้า
บริการที่ใช้งานอยู่สามารถทำงานและใช้แบตเตอรี่ได้เป็นเวลานาน
เครื่องมือติดตามบริการที่ทำงานอยู่เบื้องหน้าจะแสดงการแจ้งเตือนให้ผู้ใช้ทราบเมื่อบริการที่ทำงานอยู่เบื้องหน้าทำงานเป็นเวลานานแต่มองไม่เห็น เช่น เมื่อผู้ใช้ปิดการแจ้งเตือนของบริการ หากผู้ใช้คลิกการแจ้งเตือน ระบบจะแสดงตัวจัดการงานและอนุญาตให้ผู้ใช้หยุดบริการที่ทำงานอยู่เบื้องหน้า เครื่องมือติดตามนี้จะเปิดใช้โดยค่าเริ่มต้น
เครื่องมือติดตามการใช้งานแบตเตอรี่ในเบื้องหลัง
แอปอาจทำให้แบตเตอรี่หมดในเบื้องหลังโดยที่ผู้ใช้ไม่รู้ตัว เครื่องมือติดตามแบตเตอรี่ในเบื้องหลังจะตรวจสอบการใช้งานแบตเตอรี่ของแต่ละแอป การใช้งานแบตเตอรี่ในบริบทนี้กำหนดโดยมิติข้อมูล 3 รายการ ได้แก่ แอปที่ทำงานอยู่เบื้องหน้าบนสุด บริการที่ทำงานอยู่เบื้องหน้าซึ่งทำงานอยู่เบื้องหลัง และส่วนเบื้องหลังของแอป หากการใช้งานแบตเตอรี่ในส่วนเบื้องหลังของแอปสูงกว่าเกณฑ์ที่กำหนด ระบบจะย้ายแอปไปยังที่เก็บข้อมูลแบบจำกัดซึ่งจำกัดให้ทำงานได้เพียง 1 งานต่อวัน ระบบจะปิดใช้เครื่องมือติดตามนี้โดยค่าเริ่มต้น หากต้องการเปิดใช้เครื่องมือติดตามนี้ ให้เรียกใช้คำสั่งต่อไปนี้
adb shell device_config put activity_manager bg_auto_restrict_abusive_apps 1
adb shell device_config put activity_manager bg_current_drain_auto_restrict_abusive_apps_enabled 1
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 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-07-27 UTC"],[],[],null,["# App background behavior trackers\n\nAndroid 13 introduces the concept of a\n*power consumption tracker*, which is a process that monitors foreground or\nbackground battery usage by apps to determine if apps violate some policy.\nAndroid 13 contains two power consumption trackers:\nthe foreground service tracker and background battery usage tracker. As opposed\nto using your own mechanisms to determine battery abuse by apps, we\nrecommend using these trackers to monitor and alert users of excessive battery\nusage.\n\nForeground service tracker\n--------------------------\n\nForeground services can execute and use battery for an extended period of time.\nThe foreground service tracker displays a notification to users when a\nforeground service has been running for a long period of time but is invisible,\nsuch as when a user has dismissed the service's notification. If the user\nclicks the notification, the task manager is displayed and lets\nthe user stop the foreground service. This tracker is enabled by default.\n\nBackground battery usage tracker\n--------------------------------\n\nApps can drain battery in the background without the user being aware. The\nbackground battery tracker watches battery usage for each app. Battery usage\nin this context is defined by three dimensions: foreground app on top,\nforeground service running something that isn't visible, and background part of\napp. If the background portion of the app's battery usage crosses some threshold,\nthe app is moved into a restricted bucket limiting it to one job per day. This\ntracker is disabled by default. To enable this tracker, run the following\ncommands: \n\n adb shell device_config put activity_manager bg_auto_restrict_abusive_apps 1\n adb shell device_config put activity_manager bg_current_drain_auto_restrict_abusive_apps_enabled 1"]]