Android Guides | Samples

Android.App.ServiceAttribute Class

Generates a /manifest/application/service element within AndroidManifest.xml.

See Also: ServiceAttribute


[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class ServiceAttribute : Attribute

See Also


The //service element is used to declare a service, which are used to implement long-running background operations or a rich communicationsAPI that can be called by other applications. The ServiceAttribute custom attribute is used by monodroid.exe when generating AndroidManifest.xml to to declaratively generate //service elements.

The type this attribute is placed on must be a (possibly indirect) subclass of Service.

The following type declaration

C# Example

[Service (Name="mono.samples.HelloService", 
        Label="Service Label")]
class MyService : Service {

results in the following XML fragment:

XML Example

            android:label="Service Label" 
            android:name="mono.samples.HelloService" />

In addition, types using the ServiceAttribute custom attribute can also use the IntentFilterAttribute and MetaDataAttribute custom attributes to declaratively generate the nested //service/intent-filter and //service/meta-data elements, respectively.


Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:

The members of Android.App.ServiceAttribute are listed below.

See Also: Attribute

Public Constructors

Constructs and initializes a new ServiceAttribute instance.

Public Properties

EnabledBoolean. Whether or not the service can be instantiated by the system.
ExportedBoolean. Whether or not the service can be launched by components of other applications.
IconString. An icon representing the service.
LabelString. A user-readable label for the service.
NameString. The name of the class that implements the service.
PermissionString. The name of a permission that clients must have to launch the service.
ProcessString. The name of the process in which the service should run.