ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จำกัดสถานที่ตั้งที่มีโอกาส
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เมื่อแอปขอตำแหน่งของอุปกรณ์ แอปจะรอการตอบกลับคำขอหรือรับการอัปเดตตำแหน่งตามโอกาสโดยใช้เครื่องมือรับฟังตำแหน่งที่ทำงานอยู่ก็ได้ ตัวเลือกนี้พร้อมใช้งาน (ไม่จํากัด) ใน Android 9 และต่ำกว่า และแสดงเมื่อแอประบุเฉพาะอัตราการอัปเดตตําแหน่งแบบแอ็กทีฟ โดยปล่อยอัตราการอัปเดตแบบพาสซีฟว่างไว้
(โปรแกรมฟังตำแหน่งแบบไม่ระบุตัวตนจะไม่ได้รับการอัปเดตตำแหน่งแบบมีโอกาส เนื่องจากไม่ได้ระบุอัตราการอัปเดตตำแหน่ง)
ตั้งแต่ Android 10 เป็นต้นไป หากต้องการรับการอัปเดตตำแหน่งแบบไม่ระบุแหล่งที่มา นักพัฒนาแอปต้องระบุว่าต้องการการอัปเดตตำแหน่งแบบไม่ระบุแหล่งที่มาจากคลาส FusedLocationProviderClient
ผู้ให้บริการ Fused Location
แอประบุอัตราที่จะได้รับข้อมูลอัปเดตตำแหน่งแบบมีโอกาสจากFusedLocationProviderClient
คลาสได้ 2 วิธี
ผลกระทบ
หากคุณไม่ได้ระบุค่าสำหรับ setFastestInterval
แอปของคุณอาจได้รับการอัปเดตตำแหน่งที่ส่งถึงน้อยลงอย่างมาก
การใช้งาน
คุณไม่ต้องดําเนินการใดๆ เพื่อติดตั้งใช้งานฟีเจอร์นี้ เพียงแค่ใช้ค่าที่แนะนําสําหรับเมธอด FusedLocationProviderClient
class setFastestInterval
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Restrict opportunistic locations\n\nWhen an app requests a device's location, it can either wait for\nthe request response or, by using active location listeners, get an\nopportunistic location update. This was available (unrestricted) in\nAndroid 9 and lower, and was provided when an app specified only\nthe active location update rate, leaving the passive rate blank.\n(Passive location listeners don't receive opportunistic location\nupdates because they don't specify a location update rate.)\n\nStarting in Android 10, to get opportunistic\nlocation updates, developers must specify that they need passive location\nupdates from the **[FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location\n/FusedLocationProviderClient)** class.\n\nFused location provider\n-----------------------\n\nApps can specify the rate at which they get opportunistic location updates from the [FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient)\nclass in two ways.\n\n- Specify a value in the [setFastestInterval](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long)) method that's lower than the value of the [setInterval](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setInterval(long)) parameter. (Use a value of 0 ms or greater.)\n- Let the value be set automatically by leaving [setFastestInterval](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long)) unspecified.\n\nImpact\n------\n\nIf you don't provide a value for [setFastestInterval](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long)),\nyour app may experience a significant\nreduction in location updates delivered to it.\n\nImplementation\n--------------\n\nYou don't need to do anything to implement this feature other\nthan to use the suggested values for the [FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location\n/FusedLocationProviderClient) class [setFastestInterval](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long))\nmethod."]]