ServiceInfo.ForegroundServiceTypeSpecialUse Field
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
This constant will be removed in the future version. Use Android.Content.PM.ForegroundService enum directly instead of this field.
Constant corresponding to specialUse
in
the android.R.attr#foregroundServiceType
attribute.
[Android.Runtime.Register("FOREGROUND_SERVICE_TYPE_SPECIAL_USE", ApiSince=34)]
[Android.Runtime.RequiresPermission("android.permission.FOREGROUND_SERVICE_SPECIAL_USE")]
[System.Obsolete("This constant will be removed in the future version. Use Android.Content.PM.ForegroundService enum directly instead of this field.", true)]
public const Android.Content.PM.ForegroundService ForegroundServiceTypeSpecialUse = 1073741824;
[<Android.Runtime.Register("FOREGROUND_SERVICE_TYPE_SPECIAL_USE", ApiSince=34)>]
[<Android.Runtime.RequiresPermission("android.permission.FOREGROUND_SERVICE_SPECIAL_USE")>]
[<System.Obsolete("This constant will be removed in the future version. Use Android.Content.PM.ForegroundService enum directly instead of this field.", true)>]
val mutable ForegroundServiceTypeSpecialUse : Android.Content.PM.ForegroundService
Field Value
Value = 1073741824Implements
- Attributes
Remarks
Constant corresponding to specialUse
in the android.R.attr#foregroundServiceType
attribute. Use cases that can't be categorized into any other foreground service types, but also can't use android.app.job.JobInfo.Builder
APIs.
The use of this foreground service type may be restricted. Additionally, apps must declare a service-level PackageManager#PROPERTY_SPECIAL_USE_FGS_SUBTYPE <property>
in AndroidManifest.xml
as a hint of what the exact use case here is. Here is an example:
<uses-permission
android:name="android.permissions.FOREGROUND_SERVICE_SPECIAL_USE"
/>
<service
android:name=".MySpecialForegroundService"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="foo"
/>
</service>
In a future release of Android, if the above foreground service type foo
is supported by the platform, to offer the backward compatibility, the app could specify the android:maxSdkVersion
attribute in the <uses-permission> section, and also add the foreground service type foo
into the android:foregroundServiceType
, therefore the same app could be installed in both platforms.
<uses-permission
android:name="android.permissions.FOREGROUND_SERVICE_SPECIAL_USE"
android:maxSdkVersion="last_sdk_version_without_type_foo"
/>
<service
android:name=".MySpecialForegroundService"
android:foregroundServiceType="specialUse|foo">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="foo"
/>
</service>
Java documentation for android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.