我们将对 Android 15 中的前台服务类型进行以下更改。
جارٍ معالجة الوسائط
- نوع الخدمة التي تعمل في المقدّمة المطلوب تقديم بيان عنها في البيان ضمن
android:foregroundServiceTypemediaProcessing- الإذن المطلوب تضمينه في بيان التطبيق
FOREGROUND_SERVICE_MEDIA_PROCESSING- ثابت يتم تمريره إلى
startForeground() FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING- المتطلبات الأساسية لوقت التشغيل
- بدون
- الوصف
خدمة لتنفيذ عمليات تستغرق وقتًا طويلاً على مواد عرض الوسائط، مثل تحويل الوسائط إلى تنسيقات مختلفة يسمح النظام لهذه الخدمة بوقت محدود للعمل. وفي الظروف العادية، يكون هذا الحدّ الزمني 6 ساعات من كل 24 ساعة. (تتم مشاركة هذا الحدّ بين جميع خدمات
mediaProcessingالتي تعمل في المقدّمة في التطبيق).يجب أن يوقف تطبيقك يدويًا خدمة معالجة الوسائط في السيناريو التالي:
- عند اكتمال عملية تحويل الترميز أو وصولها إلى حالة تعذُّر، اطلب من العميل
الاتصال بخدمة
Service.stopForeground()وService.stopSelf()لإيقاف الخدمة بالكامل.
- عند اكتمال عملية تحويل الترميز أو وصولها إلى حالة تعذُّر، اطلب من العميل
الاتصال بخدمة
في حال بلوغ فترة المهلة، يستدعي النظام طريقة
Service.onTimeout(int, int)في الخدمة. في هذه اللحظة، تتوفّر للخدمة بضع ثواني للاتصال بالرقمService.stopSelf(). إذا لم تطلب الخدمةService.stopSelf()، سيحدث خطأ ANR مع ظهور رسالة الخطأ التالية: "لم يتم إيقاف الخدمة التي تعمل في المقدّمة من النوع <fgs_type> خلال مهلة الانتظار: <component_name>".ملاحظة: لا تتوفّر
Service.onTimeout(int, int)على الإصدار 14 من نظام التشغيل Android أو الإصدارات الأقدم. على الأجهزة التي تعمل بالإصدارات السابقة، إذا انتهت مهلة خدمة معالجة الوسائط، يُخزِّن النظام التطبيق في ذاكرة التخزين المؤقت على الفور. لهذا السبب، يجب ألا ينتظر تطبيقك تلقّي إشعار بانتهاء المهلة. بدلاً من ذلك، يجب إنهاء الخدمة التي تعمل في المقدّمة أو تغييرها إلى خدمة تعمل في الخلفية في أقرب وقت ممكن.
الكاميرا
Apps that target Android 15 or higher are not allowed to launch a
camera foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.
مزامنة البيانات
Apps that target Android 15 or higher are not allowed to launch a
data sync foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.
تشغيل الوسائط
Apps that target Android 15 or higher are not allowed to launch a
media playback foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.
عرض الوسائط
Apps that target Android 15 or higher are not allowed to launch a
media projection foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.
الميكروفون
Apps that target Android 14 (API level 34) or higher are not allowed to launch a
microphone foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.
المكالمات الهاتفية
Apps that target Android 15 or higher are not allowed to launch a
phone call foreground service from a BOOT_COMPLETED broadcast receiver.
For more information, see
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground
services.