(Transfer) AndroidManifest.xml file details (service)

Reprinted from: http://blog.csdn.net/think_soft/article/details/7584895

 

Syntax (SYNTAX):

<serviceAndroid:enabled=["true" | "false"]
         android:
exported=["true" | "false"]
         android:
icon="drawable resource"android:label="string resource"android:name="string"android:permission="string"android:process="string">    . . .
         
         
         
         

</service>

is contained in (CONTAINED IN):

<application>

Possible elements (CAN CONTAIN):

<intent-filter>

<meta-data>

Description (DESCRIPTION):

This element is used to declare a service (a subclass of the Service class) as one of the application's components. Unlike activities, services have no visible user interface. They are used to implement long-lived background operations, or to provide communication APIs that can be called by other applications.

All services must be represented by the <service> element in the manifest file. Any service not declared in the manifest will not be seen by the system and will not be run.

Attributes (ATTRIBUTES):

android:enabled

This property is used to indicate whether the service can be instantiated. If set to true, it can be instantiated, otherwise it cannot be instantiated. The default value is true.

The <application> element has its own enabled attribute, which applies to all components in the application, including the service component. For a service to be enabled, the enabled attributes of both the <application> and <service> elements must be true (the default is true). If an element's enabled attribute is set to false, the service is disabled and cannot be instantiated.

android:exported

This property is used to indicate whether the service can be called by or interact with other application components. Can be called or interacted with if set to true, otherwise not. When set to false, only components of the same application or applications with the same user ID can start or bind the service.

Its default value depends on the filters contained in the service. No filter means that the service can only be called by specifying an explicit class name, which means that the service can only be used inside the application (because other external consumers will not know the class name of the service), so this In this case, the default value of this property is false. On the other hand, if at least one filter is included, it means that the service can provide services to other external applications, so the default value is true.

This property is not the only way to limit the exposure of the service to other applications. Permissions can also be used to restrict external entities that can interact with the service.

android:icon

This property defines an icon representing the service, which must reference a drawable resource that contains the image definition. If this attribute is not set, the icon set by the icon attribute of the <application> element is used instead.

Whether it is the icon set by the <application> element or the icon set by the <service> element, they are the default icons for all Intent filters for the service.

android:label

This property is used to set a name of the service to be displayed to users. If this attribute is not set, the value of the label attribute of the <application> element will be used instead.

Whether it is the tag set by <service> or the tag set by the <application> element, they are the default tags for all intent filters of the service.

This tag should refer to a string resource so that it can be localized like strings in the user interface. However, for the convenience of developing applications, you can also use a native string to set this property.

android:name

This attribute is used to specify the class name of the Service subclass that implements the service. It should be the full Java class name (eg: com.example.project.RoomService). However, a shorthand (eg: .RoomService) can also be used, and the system will prepend the value set by the package attribute in the <manifest> element to the front of the shorthand name.

Once the application is published, this name should not be changed (unless android:exported="false").

There is no default value for this property, the name must be specified.

android:permission

This property defines the permissions that the entity that wants to start or bind the service must have. If the caller's startService(), bindService(), and stopService() methods are not granted this permission, these methods will not work and Intent objects will not be sent to the service.

If this attribute is not set, the permissions set through the <appliction> element's permission attribute will apply to the service. If the <application> element also does not have permissions set, the service is not protected by permissions.

android:process

This property is used to set the name of the process the service is running on. Typically, all components of an application run in a process created for the application with the same process name as the application's package name. The process attribute of the <application> element can set a different default name for all components of the application. But each component's own process attribute can override this default value, which allows the application to be separated into multiple processes.

 

If the property value starts with ":", the system will create a new, application-private process when needed, and the service will also run in this process. If the property value starts with a lowercase letter, then the service runs in the global process named after the property value, which provides permission to make it work. This allows different application components to share the process, thereby reducing resource usage.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326392413&siteId=291194637