ফোরগ্রাউন্ড পরিষেবার প্রকারগুলি প্রয়োজন৷

To help developers be more intentional with defining user-facing foreground services, Android 10 introduced the android:foregroundServiceType attribute within the <service> element.

If your app targets Android 14, it must specify appropriate foreground service types. As in previous versions of Android, multiple types can be combined. This list shows the foreground service types to choose from:

If a use case in your app isn't associated with any of these types, we strongly recommend that you migrate your logic to use WorkManager or user-initiated data transfer jobs.

The health, remoteMessaging, shortService, specialUse, and systemExempted types are new in Android 14.

The following code snippet provides an example of a foreground service type declaration in the manifest:

<manifest ...>
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    <application ...>
      <service
          android:name=".MyMediaPlaybackService"
          android:foregroundServiceType="mediaPlayback"
          android:exported="false">
      </service>
    </application>
</manifest>

If an app that targets Android 14 doesn't define types for a given service in the manifest, then the system will raise MissingForegroundServiceTypeException upon calling startForeground() for that service.

ফোরগ্রাউন্ড পরিষেবার প্রকারগুলি ব্যবহার করার জন্য নতুন অনুমতি ঘোষণা করুন৷

যদি Android 14 কে লক্ষ্য করে এমন অ্যাপগুলি একটি ফোরগ্রাউন্ড পরিষেবা ব্যবহার করে, তাহলে তাদের অবশ্যই একটি নির্দিষ্ট অনুমতি ঘোষণা করতে হবে, ফোরগ্রাউন্ড পরিষেবার প্রকারের উপর ভিত্তি করে, যা Android 14 প্রবর্তন করে। এই অনুমতিগুলি এই পৃষ্ঠার প্রতিটি ফোরগ্রাউন্ড পরিষেবা টাইপ বিভাগের জন্য উদ্দিষ্ট ব্যবহারের ক্ষেত্রে এবং প্রয়োগের ক্ষেত্রে "অনুমতি যা আপনাকে অবশ্যই আপনার ম্যানিফেস্ট ফাইলে ঘোষণা করতে হবে" লেবেলযুক্ত বিভাগগুলিতে উপস্থিত হয়৷

সমস্ত অনুমতি সাধারণ অনুমতি হিসাবে সংজ্ঞায়িত করা হয় এবং ডিফল্টরূপে দেওয়া হয়। ব্যবহারকারীরা এই অনুমতি প্রত্যাহার করতে পারবেন না।

রানটাইমে অগ্রভাগের পরিষেবার ধরন অন্তর্ভুক্ত করুন

The best practice for applications starting foreground services is to use the ServiceCompat version of startForeground() (available in androidx-core 1.12 and higher) where you pass in a bitwise integer of foreground service types. You can choose to pass one or more type values.

Usually, you should declare only the types required for a particular use case. This makes it easier to meet the system's expectations for each foreground service type. In cases where a foreground service is started with multiple types, then the foreground service must adhere to the platform enforcement requirements of all types.

ServiceCompat.startForeground(0, notification, FOREGROUND_SERVICE_TYPE_LOCATION)

If the foreground service type is not specified in the call, the type defaults to the values defined in the manifest. If you didn't specify the service type in the manifest, the system throws MissingForegroundServiceTypeException.

If the foreground service needs new permissions after you launch it, you should call startForeground() again and add the new service types. For example, suppose a fitness app runs a running-tracker service that always needs location information, but might or might not need media permissions. You would need to declare both location and mediaPlayback in the manifest. If a user starts a run and just wants their location tracked, your app should call startForeground() and pass just the location service type. Then, if the user wants to start playing audio, call startForeground() again and pass location|mediaPlayback.

সিস্টেম রানটাইম চেক

সিস্টেমটি ফোরগ্রাউন্ড পরিষেবার ধরনগুলির সঠিক ব্যবহারের জন্য পরীক্ষা করে এবং নিশ্চিত করে যে অ্যাপটি সঠিক রানটাইম অনুমতির জন্য অনুরোধ করেছে বা প্রয়োজনীয় API ব্যবহার করেছে৷ উদাহরণস্বরূপ, সিস্টেম আশা করে যে অ্যাপগুলি ফোরগ্রাউন্ড পরিষেবার প্রকার FOREGROUND_SERVICE_TYPE_LOCATION ব্যবহার করে ACCESS_COARSE_LOCATION বা ACCESS_FINE_LOCATION এর জন্য অনুরোধ করবে৷

এটি বোঝায় যে ব্যবহারকারীর কাছ থেকে অনুমতির অনুরোধ করার সময় এবং ফোরগ্রাউন্ড পরিষেবাগুলি শুরু করার সময় অ্যাপগুলিকে অবশ্যই একটি নির্দিষ্ট ক্রিয়াকলাপ অনুসরণ করতে হবে৷ অ্যাপটি startForeground() কে কল করার চেষ্টা করার আগে অনুমতির অনুরোধ করতে হবে এবং মঞ্জুর করতে হবে। যে অ্যাপগুলি ফোরগ্রাউন্ড পরিষেবা শুরু হওয়ার পরে উপযুক্ত অনুমতিগুলির জন্য অনুরোধ করে তাদের অবশ্যই এই ক্রিয়াকলাপের ক্রম পরিবর্তন করতে হবে এবং ফোরগ্রাউন্ড পরিষেবা শুরু করার আগে অনুমতির অনুরোধ করতে হবে৷

প্ল্যাটফর্ম প্রয়োগের সুনির্দিষ্ট বৈশিষ্ট্যগুলি এই পৃষ্ঠার প্রতিটি ফোরগ্রাউন্ড পরিষেবা প্রকার বিভাগের জন্য উদ্দেশ্যমূলক ব্যবহারের ক্ষেত্রে এবং প্রয়োগের ক্ষেত্রে "রানটাইম প্রয়োজনীয়তা" লেবেলযুক্ত বিভাগগুলিতে প্রদর্শিত হয়।

প্রতিটি ফোরগ্রাউন্ড পরিষেবার প্রকারের জন্য উদ্দেশ্যযুক্ত ব্যবহারের ক্ষেত্রে এবং প্রয়োগ

为了使用给定的前台服务类型,您必须在清单文件中声明特定权限,必须满足特定的运行时要求,并且应用必须满足该类型的其中一组预期用例。以下部分介绍了您必须声明的权限、运行时前提条件以及每种类型的预期用例。

ক্যামেরা

要在 android:foregroundServiceType 下在清单中声明的前台服务类型
camera
在清单中声明的权限
FOREGROUND_SERVICE_CAMERA
要传递给 startForeground() 的常量
FOREGROUND_SERVICE_TYPE_CAMERA
运行时前提条件

请求并获得 CAMERA 运行时权限

注意CAMERA 运行时权限受使用时限制的约束。因此,除少数例外情况外,您无法在应用在后台运行时创建 camera 前台服务。如需了解详情,请参阅与启动需要“使用时”权限的前台服务相关的限制

说明

继续在后台访问相机,例如支持多任务的视频聊天应用。

সংযুক্ত ডিভাইস

ফোরগ্রাউন্ড সার্ভিস টাইপ যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
connectedDevice
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_CONNECTED_DEVICE
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
রানটাইম পূর্বশর্ত

নিম্নলিখিত শর্তগুলির মধ্যে অন্তত একটি সত্য হতে হবে:

বর্ণনা

ব্লুটুথ, এনএফসি, আইআর, ইউএসবি বা নেটওয়ার্ক সংযোগের প্রয়োজন বাহ্যিক ডিভাইসগুলির সাথে মিথস্ক্রিয়া।

বিকল্প

যদি আপনার অ্যাপটিকে একটি বাহ্যিক ডিভাইসে ক্রমাগত ডেটা স্থানান্তর করতে হয়, তবে পরিবর্তে সহচর ডিভাইস ম্যানেজার ব্যবহার করার কথা বিবেচনা করুন। সহচর ডিভাইসের পরিসরে থাকাকালীন আপনার অ্যাপটি চলমান থাকতে সাহায্য করার জন্য সহচর ডিভাইস উপস্থিতি API ব্যবহার করুন৷

আপনার অ্যাপটিকে ব্লুটুথ ডিভাইসের জন্য স্ক্যান করার প্রয়োজন হলে, পরিবর্তে ব্লুটুথ স্ক্যান API ব্যবহার করার কথা বিবেচনা করুন।

ডেটা সিঙ্ক

要在清单中的以下位置声明的前台服务类型
android:foregroundServiceType
dataSync
在清单中声明的权限
FOREGROUND_SERVICE_DATA_SYNC
要传递给 startForeground() 的常量
FOREGROUND_SERVICE_TYPE_DATA_SYNC
运行时前提条件
说明

数据传输操作,例如:

  • 数据上传或下载
  • 备份和恢复操作
  • 导入或导出操作
  • 获取数据
  • 本地文件处理
  • 通过网络在设备和云端之间传输数据
替代方案

如需了解详情,请参阅数据同步前台服务的替代方案

স্বাস্থ্য

Foreground service type to declare in manifest under
android:foregroundServiceType
health
Permission to declare in your manifest
FOREGROUND_SERVICE_HEALTH
Constant to pass to startForeground()
FOREGROUND_SERVICE_TYPE_HEALTH
Runtime prerequisites

At least one of the following conditions must be true:

Note: The BODY_SENSORS and sensor-based READ runtime permissions are subject to while-in-use restrictions. For this reason, you cannot create a health foreground service that uses body sensors while your app is in the background unless you've been granted the BODY_SENSORS_BACKGROUND (API level 33 to 35) or READ_HEALTH_DATA_IN_BACKGROUND (API level 36 and higher) permissions. For more information, see Restrictions on starting foreground services that need while-in-use permissions.

Description

Any long-running use cases to support apps in the fitness category such as exercise trackers.

অবস্থান

要在清单中的以下位置声明的前台服务类型
android:foregroundServiceType
location
在清单中声明的权限
FOREGROUND_SERVICE_LOCATION
要传递给 startForeground() 的常量
FOREGROUND_SERVICE_TYPE_LOCATION
运行时前提条件

用户必须已启用位置信息服务,并且应用必须至少获得以下一项运行时权限:

注意:如需检查用户是否已启用位置信息服务以及是否已授予对运行时权限的访问权限,请使用 PermissionChecker#checkSelfPermission()

注意:位置信息运行时权限受“使用期间”限制。因此,除非您已获得 ACCESS_BACKGROUND_LOCATION 运行时权限,否则无法在应用在后台运行时创建 location 前台服务。如需了解详情,请参阅与启动需要“使用时”权限的前台服务相关的限制

说明

需要位置信息使用权的长时间运行的用例,例如导航和位置信息分享。

替代方案

如果您的应用需要在用户到达特定位置时触发,请考虑改用 Geofence API

মিডিয়া

要在清单中的以下位置声明的前台服务类型
android:foregroundServiceType
mediaPlayback
在清单中声明的权限
FOREGROUND_SERVICE_MEDIA_PLAYBACK
要传递给 startForeground() 的常量
FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
运行时前提条件
说明
在后台继续播放音频或视频。在 Android TV 上支持数字视频录制 (DVR) 功能。
替代方案
如果您要显示画中画视频,请使用画中画模式

মিডিয়া অভিক্ষেপ

ফোরগ্রাউন্ড পরিষেবার ধরন যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
mediaProjection
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_MEDIA_PROJECTION
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
রানটাইম পূর্বশর্ত

ফোরগ্রাউন্ড পরিষেবা শুরু করার আগে createScreenCaptureIntent() পদ্ধতিতে কল করুন। এটি করা ব্যবহারকারীকে একটি অনুমতি বিজ্ঞপ্তি দেখায়; আপনি পরিষেবা তৈরি করার আগে ব্যবহারকারীকে অবশ্যই অনুমতি দিতে হবে।

আপনি ফোরগ্রাউন্ড পরিষেবা তৈরি করার পরে, আপনি MediaProjectionManager.getMediaProjection() কল করতে পারেন।

বর্ণনা

MediaProjection APIs ব্যবহার করে নন-প্রাথমিক ডিসপ্লে বা বাহ্যিক ডিভাইসে প্রজেক্ট কন্টেন্ট। এই বিষয়বস্তু একচেটিয়াভাবে মিডিয়া বিষয়বস্তু হতে হবে না.

বিকল্প

অন্য ডিভাইসে মিডিয়া স্ট্রিম করতে, Google Cast SDK ব্যবহার করুন৷

,
ফোরগ্রাউন্ড পরিষেবার ধরন যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
mediaProjection
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_MEDIA_PROJECTION
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
রানটাইম পূর্বশর্ত

ফোরগ্রাউন্ড পরিষেবা শুরু করার আগে createScreenCaptureIntent() পদ্ধতিতে কল করুন। এটি করা ব্যবহারকারীকে একটি অনুমতি বিজ্ঞপ্তি দেখায়; আপনি পরিষেবা তৈরি করার আগে ব্যবহারকারীকে অবশ্যই অনুমতি দিতে হবে।

আপনি ফোরগ্রাউন্ড পরিষেবা তৈরি করার পরে, আপনি MediaProjectionManager.getMediaProjection() কল করতে পারেন।

বর্ণনা

MediaProjection APIs ব্যবহার করে নন-প্রাথমিক ডিসপ্লে বা বাহ্যিক ডিভাইসে প্রজেক্ট কন্টেন্ট। এই বিষয়বস্তু একচেটিয়াভাবে মিডিয়া বিষয়বস্তু হতে হবে না.

বিকল্প

অন্য ডিভাইসে মিডিয়া স্ট্রিম করতে, Google Cast SDK ব্যবহার করুন৷

,
ফোরগ্রাউন্ড পরিষেবার ধরন যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
mediaProjection
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_MEDIA_PROJECTION
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
রানটাইম পূর্বশর্ত

ফোরগ্রাউন্ড পরিষেবা শুরু করার আগে createScreenCaptureIntent() পদ্ধতিতে কল করুন। এটি করা ব্যবহারকারীকে একটি অনুমতি বিজ্ঞপ্তি দেখায়; আপনি পরিষেবা তৈরি করার আগে ব্যবহারকারীকে অবশ্যই অনুমতি দিতে হবে।

আপনি ফোরগ্রাউন্ড পরিষেবা তৈরি করার পরে, আপনি MediaProjectionManager.getMediaProjection() কল করতে পারেন।

বর্ণনা

MediaProjection APIs ব্যবহার করে নন-প্রাথমিক ডিসপ্লে বা বাহ্যিক ডিভাইসে প্রজেক্ট কন্টেন্ট। এই বিষয়বস্তু একচেটিয়াভাবে মিডিয়া বিষয়বস্তু হতে হবে না.

বিকল্প

অন্য ডিভাইসে মিডিয়া স্ট্রিম করতে, Google Cast SDK ব্যবহার করুন৷

,
ফোরগ্রাউন্ড পরিষেবার ধরন যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
mediaProjection
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_MEDIA_PROJECTION
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
রানটাইম পূর্বশর্ত

ফোরগ্রাউন্ড পরিষেবা শুরু করার আগে createScreenCaptureIntent() পদ্ধতিতে কল করুন। এটি করা ব্যবহারকারীকে একটি অনুমতি বিজ্ঞপ্তি দেখায়; আপনি পরিষেবা তৈরি করার আগে ব্যবহারকারীকে অবশ্যই অনুমতি দিতে হবে।

আপনি ফোরগ্রাউন্ড পরিষেবা তৈরি করার পরে, আপনি MediaProjectionManager.getMediaProjection() কল করতে পারেন।

বর্ণনা

MediaProjection APIs ব্যবহার করে নন-প্রাথমিক ডিসপ্লে বা বাহ্যিক ডিভাইসে প্রজেক্ট কন্টেন্ট। এই বিষয়বস্তু একচেটিয়াভাবে মিডিয়া বিষয়বস্তু হতে হবে না.

বিকল্প

অন্য ডিভাইসে মিডিয়া স্ট্রিম করতে, Google Cast SDK ব্যবহার করুন৷

মাইক্রোফোন

ফোরগ্রাউন্ড সার্ভিস টাইপ যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
microphone
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_MICROPHONE
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_MICROPHONE
রানটাইম পূর্বশর্ত

অনুরোধ করুন এবং RECORD_AUDIO রানটাইম অনুমতি মঞ্জুর করুন৷

দ্রষ্টব্য: RECORD_AUDIO রানটাইম অনুমতি ব্যবহারের সময় বিধিনিষেধ সাপেক্ষে। এই কারণে, কিছু ব্যতিক্রম ছাড়া আপনার অ্যাপটি ব্যাকগ্রাউন্ডে থাকাকালীন আপনি একটি microphone ফোরগ্রাউন্ড পরিষেবা তৈরি করতে পারবেন না৷ আরও তথ্যের জন্য, ফোরগ্রাউন্ড পরিষেবাগুলি শুরু করার বিধিনিষেধগুলি দেখুন যার ব্যবহারের সময় অনুমতি প্রয়োজন

বর্ণনা

পটভূমি থেকে মাইক্রোফোন ক্যাপচার চালিয়ে যান, যেমন ভয়েস রেকর্ডার বা যোগাযোগ অ্যাপ।

ফোন কল

ফোরগ্রাউন্ড সার্ভিস টাইপ যা ম্যানিফেস্টের অধীনে ঘোষণা করতে হবে
android:foregroundServiceType
phoneCall
আপনার ম্যানিফেস্টে ঘোষণা করার অনুমতি
FOREGROUND_SERVICE_PHONE_CALL
startForeground() এ পাস করার জন্য ধ্রুবক
FOREGROUND_SERVICE_TYPE_PHONE_CALL
রানটাইম পূর্বশর্ত

এই শর্তগুলির মধ্যে অন্তত একটি সত্য হতে হবে:

  • অ্যাপ তার ম্যানিফেস্ট ফাইলে MANAGE_OWN_CALLS অনুমতি ঘোষণা করেছে।
  • অ্যাপ হল ROLE_DIALER ভূমিকার মাধ্যমে ডিফল্ট ডায়ালার অ্যাপ।
বর্ণনা

ConnectionService API ব্যবহার করে একটি চলমান কল চালিয়ে যান।

বিকল্প

আপনার যদি ফোন, ভিডিও বা ভিওআইপি কল করার প্রয়োজন হয়, তাহলে android.telecom লাইব্রেরি ব্যবহার করার কথা বিবেচনা করুন।

কল স্ক্রিন করতে CallScreeningService ব্যবহার করার কথা বিবেচনা করুন।

রিমোট মেসেজিং

Foreground service type to declare in manifest under
android:foregroundServiceType
remoteMessaging
Permission to declare in your manifest
FOREGROUND_SERVICE_REMOTE_MESSAGING
Constant to pass to startForeground()
FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING
Runtime prerequisites
None
Description
Transfer text messages from one device to another. Assists with continuity of a user's messaging tasks when they switch devices.

সংক্ষিপ্ত পরিষেবা

Foreground service type to declare in manifest under
android:foregroundServiceType
shortService
Permission to declare in your manifest
None
Constant to pass to startForeground()
FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
Runtime prerequisites
None
Description

Quickly finish critical work that cannot be interrupted or postponed.

This type has some unique characteristics:

  • Can only run for a short period of time (about 3 minutes).
  • No support for sticky foreground services.
  • Cannot start other foreground services.
  • Doesn't require a type-specific permission, though it still requires the FOREGROUND_SERVICE permission.
  • A shortService can only change to another service type if the app is currently eligible to start a new foreground service.
  • A foreground service can change its type to shortService at any time, at which point the timeout period begins.

The timeout for shortService begins from the moment that Service.startForeground() is called. The app is expected to call Service.stopSelf() or Service.stopForeground() before the timeout occurs. Otherwise, the new Service.onTimeout() is called, giving apps a brief opportunity to call stopSelf() or stopForeground() to stop their service.

A short time after Service.onTimeout() is called, the app enters a cached state and is no longer considered to be in the foreground, unless the user is actively interacting with the app. A short time after the app is cached and the service has not stopped, the app receives an ANR. The ANR message mentions FOREGROUND_SERVICE_TYPE_SHORT_SERVICE. For these reasons, it's considered best practice to implement the Service.onTimeout() callback.

The Service.onTimeout() callback doesn't exist on Android 13 and lower. If the same service runs on such devices, it doesn't receive a timeout, nor does it ANR. Make sure that your service stops as soon as it finishes the processing task, even if it hasn't received the Service.onTimeout() callback yet.

It's important to note that if the timeout of the shortService is not respected, the app will ANR even if it has other valid foreground services or other app lifecycle processes running.

If an app is visible to the user or satisfies one of the exemptions that allow foreground services to be started from the background, calling Service.StartForeground() again with the FOREGROUND_SERVICE_TYPE_SHORT_SERVICE parameter extends the timeout by another 3 minutes. If the app isn't visible to the user and doesn't satisfy one of the exemptions, any attempt to start another foreground service, regardless of type, causes a ForegroundServiceStartNotAllowedException.

If a user disables battery optimization for your app, it's still affected by the timeout of shortService FGS.

If you start a foreground service that includes the shortService type and another foreground service type, the system ignores the shortService type declaration. However, the service must still adhere to the prerequisites of the other declared types. For more information, see the Foreground services documentation.

বিশেষ ব্যবহার

要在清单中声明的前台服务类型
android:foregroundServiceType
specialUse
在清单中声明的权限
FOREGROUND_SERVICE_SPECIAL_USE
要传递给 startForeground() 的常量
FOREGROUND_SERVICE_TYPE_SPECIAL_USE
运行时前提条件
说明

涵盖其他前台服务类型未涵盖的所有有效前台服务用例。

除了声明 FOREGROUND_SERVICE_TYPE_SPECIAL_USE 前台服务类型之外,开发者还应在清单中声明用例。为此,他们会在 <service> 元素内指定 <property> 元素。这些值和相应的应用场景 。用途 您提供的案例均为自由形式,因此,您应确保提供足够的 相关信息,让审核人员了解您为何需要使用 specialUse 类型。

<service android:name="fooService" android:foregroundServiceType="specialUse">
  <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
      android:value="explanation_for_special_use"/>
</service>

সিস্টেম অব্যাহতি

Foreground service type to declare in manifest under
android:foregroundServiceType
systemExempted
Permission to declare in your manifest
FOREGROUND_SERVICE_SYSTEM_EXEMPTED
Constant to pass to startForeground()
FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED
Runtime prerequisites
None
Description

Reserved for system applications and specific system integrations, to continue to use foreground services.

To use this type, an app must meet at least one of the following criteria:

  • Device is in demo mode state
  • App is a Device Owner
  • App is a Profiler Owner
  • Safety Apps that have the ROLE_EMERGENCY role
  • Device Admin apps
  • Apps holding SCHEDULE_EXACT_ALARM or USE_EXACT_ALARM permission and are using Foreground Service to continue alarms in the background, including haptics-only alarms.
  • VPN apps (configured using Settings > Network & Internet > VPN)

    Otherwise, declaring this type causes the system to throw a ForegroundServiceTypeNotAllowedException.

ফোরগ্রাউন্ড পরিষেবার প্রকারগুলি ব্যবহার করার জন্য Google Play নীতি প্রয়োগ

如果您的应用以 Android 14 或更高版本为目标平台,您需要在 Play 管理中心的“应用内容”页面(政策 > 应用内容)中声明应用的前台服务类型。如需详细了解如何在 Play 管理中心内声明前台服务类型,请参阅了解前台服务和全屏 intent 要求