Android Development-api Guide-<service>

Source: Internet
Author: User

<service>

English Original: http://developer.android.com/guide/topics/manifest/service-element.html
Acquisition (update) Date: 2014-7-2
Moved from the original blog: http://blog.sina.com.cn/s/blog_48d491300100zmva.html

Grammar:
<service android:enabled=["true"|"false"] android:exported=["true"|"false"] Android:icon="drawable Resource"android:isolatedprocess=["true"|"false"] Android:label="string Resource"Android:name="string"android:permission="string"android:process="string">      . . . </service>
Included in:
<application>
can include:
<intent-filter>
<meta-data>
Description
declares a service ( Service subclass) and becomes a component of the application. Unlike Activity, the service lacks a visual user interface. Services are used to implement long-running background operations, or APIs that can be called by other applications for frequent communication.

All services must be declared with an element in the Manifest file <service> . Any undeclared service will be ignored by the system and will certainly not be run.

Property:
android:enabled
whether the service can be instantiated by the system-"" Yes, "" true false is not allowed. The default value is " true ".

<application> Elements have their own enabled properties that apply to all internal components of the application, including services. The service needs to be enabled, <application> and <service> This property must be set to " true " (both default values). If either of these is " false ", the service is disabled and it cannot be instantiated.

android:exported
whether the components of other applications can invoke the service or interact with the service-" true " Yes, " false " cannot. If set to false , only components of the same program as the application or user ID can start or bind the service.

The default value depends on whether the service contains Intent filters. If you do not include any filters, it means that you can only invoke them by specifying the exact class name of the Intent object. This means that the service is only used internally by the application (because other applications typically do not know the exact class name). The default value at this point is "false". On the other hand, if more than one filter is present, the service is willing to be used externally, so the default value is " true ".

This property is not the only way to limit the extent to which a service is exposed to other applications. You can also use the permissions mechanism to restrict external objects that can interact with the service (see permission properties).

android:icon
represents the icon for the service. This property must be set to a reference to the drawable resource that contains the definition of the picture. If this property value is not set, the global application icon is used instead. (see <application> 元素的icon属性)。

Service icon-whether it's here or in <application> 元素中设置的 — 同时也是本服务中所有 Intent 过滤器的默认图标(参阅 <intent-filter> 元素的icon属性)。

android:isolatedProcess
if set to true, the service will run in a special process. The process is isolated from the rest of the system and does not have its own permissions. The only way to communicate with them is through the Service API (BIND and start).
android:label
the name of the service for the user to view. If this property is not set, the global Application text label is used instead (see <application> attributes of the element label ).

The text label of the service-whether it is set here or in the element-is also the <application> default text label for all Intent filters in the service (see <intent-filter> attributes of the element label ).

This label should be set as a reference to a string resource so that it can be localized like any other string in the user interface. However, it can also be set directly to a string for ease of application development.

android:name
Service The name of the child class that implements the service. This should be a fully qualified class name (such as " com.example.project.RoomService "). However, if the first character is a period (for example, " .RoomService "), the <manifest> package name defined by the element is prepended to it.

Once the application is published, the name should no longer be changed (unless it is set android:exported="false" ).

There is no default value. This name must be specified.

android:permission
The name of the permission that must be owned by the object to start or bind the service. If startService() , bindService() or stopService() the caller does not have the permissions set by this property, these methods will be invalidated and the Intent object will not be distributed to the service.

If this property is not set, the <application> permissions defined by the element's properties are applied permission to the service. If the properties are not set in two places, the service will not be protected by a permission mechanism.

For more information about permissions, see the Permissions section in the Manifest introduction article and another document security and permissions.

android:process
the name of the process running the service. Typically, all components of an application run in the default process at the time of creation. The name of the process is the same as the package name. <application> the attributes of an element process can set a different default process for each component. But each component can also override the default settings with its own process properties, allowing the program to run across multiple processes.

If the name set by this property begins with a colon (': '), a process that is private to the program will be created if necessary, and the service will run in that new process. If the process name starts with a lowercase letter, the service runs in a global process named this name and gives the appropriate access. This allows multiple components belonging to different applications to share the same process to reduce the resource footprint.

See:
<application>
<activity>
Introduced from:
API Level 1

Android Development-api Guide-<service>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.