AI2 Component  (Version nb184)
com.google.appinventor.components.annotations.androidmanifest.ServiceElement Interface Reference

Public Member Functions

IntentFilterElement[] intentFilters () default
 
MetaDataElement[] metaDataElements () default
 
String name ()
 
String isolatedProcess () default ""
 
String foregroundServiceType () default ""
 
String description () default ""
 
String directBootAware () default ""
 
String enabled () default ""
 
String exported () default ""
 
String icon () default ""
 
String label () default ""
 
String permission () default ""
 
String process () default ""
 

Detailed Description

Annotation to describe a <service> element required by a component so that it can be added to AndroidManifest.xml. <service> elements indicate that a component is a service. <service> element attributes that are not set explicitly default to "" or {} and are ignored when the element is created in the manifest.

Note: Most of this documentation is adapted from the Android framework specification linked below. That documentation is licensed under the ahref="https://creativecommons.org/licenses/by/2.5/">CreativeCommonsAttributionlicensev2.5</a>.See@link<ahref="https://developer.android.com/guide/topics/manifest/service-element">https://developer.android.com/guide/topics/manifest/service-element</a>.@authorhttps://github.com/ShreyashSaitwal(ShreyashSaitwal)

Definition at line 35 of file ServiceElement.java.

Member Function Documentation

◆ description()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.description ( )

A string that describes the service to users. The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.

Returns
the service desciption attribute

◆ directBootAware()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.directBootAware ( )

Whether or not the service is direct-boot aware; that is, whether or not it can run before the user unlocks the device.

Returns
the service directBootAware attribute

◆ enabled()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.enabled ( )

Whether or not the service can be instantiated by the system — "true" if it can be, and "false" if not. The default value is "true". The <application> element has its own enabled attribute that applies to all application components, including services. The <application> and <service> attributes must both be "true" (as they both are by default) for the service to be enabled. If either is "false", the service is disabled; it cannot be instantiated.

Returns
the service enabled attribute

◆ exported()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.exported ( )

Whether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not. When the value is "false", only components of the same application or applications with the same user ID can start the service or bind to it.

The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true".

This attribute is not the only way to limit the exposure of a service to other applications. You can also use a permission to limit the external entities that can interact with the service.

Returns
the service exported attribute

◆ foregroundServiceType()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.foregroundServiceType ( )

Specify that the service is a foreground service that satisfies a particular use case. For example, a foreground service type of "location" indicates that an app is getting the device's current location, usually to continue a user-initiated action related to device location. You can assign multiple foreground service types to a particular service.

Returns
the service foregroundServiceType attribute

◆ icon()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.icon ( )

An icon representing the service. This attribute must be set as a reference to a drawable resource containing the image definition. If it is not set, the icon specified for the application as a whole is used instead.

The service's icon — whether set here or by the <application> element — is also the default icon for all the service's intent filters (see the IntentFilterElement#icon() attribute).

Returns
the service icon attribute

◆ intentFilters()

IntentFilterElement [] com.google.appinventor.components.annotations.androidmanifest.ServiceElement.intentFilters ( )

An array containing any intent filters used by this <service> element.

Returns
an array containing the <intent-filter> subelements for this <service> element

Definition at line 42 of file ServiceElement.java.

◆ isolatedProcess()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.isolatedProcess ( )

If set to true, this service will run under a special process that is isolated from the rest of the system and has no permissions of its own. The only communication with it is through the Service API (binding and starting).

Returns
the service isolatedProcess attribute

◆ label()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.label ( )

A name for the service that can be displayed to users. If this attribute is not set, the label set for the application as a whole is used instead.

The service's label — whether set here or by the <application> element — is also the default label for all the service's intent filters.

Returns
the service label attribute

◆ metaDataElements()

MetaDataElement [] com.google.appinventor.components.annotations.androidmanifest.ServiceElement.metaDataElements ( )

An array containing any meta data used by this <service> element.

Returns
an array containing the <meta-data> subelements for this <service> element

Definition at line 50 of file ServiceElement.java.

◆ name()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.name ( )

The name of the class that implements the service. This should be a fully qualified class name (such as, "com.example.project.RoomService"). However, as a shorthand, if the first character of the name is a period (for example, ".RoomService"), it is appended to the package name of the application.

Returns
the Service class name

◆ permission()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.permission ( )

The name of a permission that an entity must have in order to launch the service or bind to it. If a caller of startService(), bindService(), or stopService(), has not been granted this permission, the method will not work and the Intent object will not be delivered to the service.

If this attribute is not set, the permission set by the <application> element's permission attribute applies to the service. If neither attribute is set, the service is not protected by a permission.

Returns
the service permission attribute

◆ process()

String com.google.appinventor.components.annotations.androidmanifest.ServiceElement.process ( )

The name of the process in which the service should run. Normally, all components of an application run in the default process created for the application. For our purposes, those components are services and activities. It has the same name as the application package. Each component can override the default with its own process attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the service runs in that process. If the process name begins with a lowercase character, the service will run in a global process of that name, provided that it has permission to do so. This allows components ( services and activities) in different applications to share a process, reducing resource usage.

Returns
the service process attribute

The documentation for this interface was generated from the following file: