ServiceInfo.ForegroundServiceTypeSpecialUse Field

Definition

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 = 1073741824

Implements

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 &lt;property&gt; in AndroidManifest.xml as a hint of what the exact use case here is. Here is an example:

&lt;uses-permission
                 android:name="android.permissions.FOREGROUND_SERVICE_SPECIAL_USE"
             /&gt;
             &lt;service
                 android:name=".MySpecialForegroundService"
                 android:foregroundServiceType="specialUse"&gt;
                 &lt;property
                     android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                     android:value="foo"
                 /&gt;
            &lt;/service&gt;

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 &lt;uses-permission&gt; section, and also add the foreground service type foo into the android:foregroundServiceType, therefore the same app could be installed in both platforms.

&lt;uses-permission
                 android:name="android.permissions.FOREGROUND_SERVICE_SPECIAL_USE"
                 android:maxSdkVersion="last_sdk_version_without_type_foo"
             /&gt;
             &lt;service
                 android:name=".MySpecialForegroundService"
                 android:foregroundServiceType="specialUse|foo"&gt;
                 &lt;property
                     android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                     android:value="foo"
                 /&gt;
            &lt;/service&gt;

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.

Applies to