اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
حظر المواقع الجغرافية التي يتم تحديدها بشكل عشوائي
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
عندما يطلب تطبيق الموقع الجغرافي للجهاز، يمكنه إما الانتظار للحصول على
استجابة الطلب أو الحصول على
تعديل موقع جغرافي مناسب باستخدام مستمعي الموقع الجغرافي النشطين. كان هذا الخيار متاحًا (بدون قيود) في الإصدار 9 من نظام التشغيل Android والإصدارات الأقدم، وكان متاحًا عندما يحدِّد التطبيق فقط معدل تعديل الموقع الجغرافي النشط، ويترك معدل التعديل التلقائي فارغًا.
(لا تتلقّى تطبيقات الاستماع السلبي إلى الموقع الجغرافي تحديثات موقع جغرافي opportunistic
لأنّها لا تحدّد معدّل تحديث الموقع الجغرافي).
بدءًا من الإصدار Android 10، للحصول على تعديلات opportunistic
للموقع الجغرافي، على المطوّرين تحديد أنّهم بحاجة إلى تعديلات
passive للموقع الجغرافي من فئة FusedLocationProviderClient
.
موفِّر الموقع المدمج
يمكن للتطبيقات تحديد معدّل تلقّي آخر المعلومات المتعلّقة بالموقع الجغرافي من فئة FusedLocationProviderClient
بطريقتَين.
التأثير
في حال عدم تقديم قيمة لسمة setFastestInterval
،
قد يشهد تطبيقك انخفاضًا كبيرًا
في عدد تحديثات الموقع الجغرافي التي يتم إرسالها إليه.
التنفيذ
لا تحتاج إلى اتّخاذ أي إجراء لتنفيذ هذه الميزة سوى
استخدام القيم المقترَحة لطريقة FusedLocationProviderClient
class setFastestInterval
.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]