android manifest.xml配置文件中的 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(Service的子类)作为应用程序的组件。 与activities不同,services没有用户界面。它们被用来实现了后台长期运行操作或者提供一个丰富的交互API供其它应用程序使用。所有的service在manifest文件中用标签代表。android系统不能发现没有声明在manifest文件中的service,service将不能运行。


属性集:
android:enabled
指示这个service是否能被android系统实例化。true:能实例化,false:不能实例化。默认值:true。
标签也有 enabled 属性。这个属性应用到所有的应用程序组件,包括其中的services。 的enabled属性必须都设置为 true时,service才是可被实例化的。任何一个的enabled属性被设置为fase,service不能被实例化。


android:exported
指示其他应用程序的组件是否可以调用service或者和service交互。true:可以,false:不可以。当值是false的时候,仅有本应用程序的组件或者有相同的USER ID的应用能启动service或者绑定service。默认值依赖于service包含的 intent filters。如果没有包含filters表示能够通过指定sevice详细的类名调用service。这意味着service倾向于仅仅是为应用程序内部使用,因为其他人不知道service的类名。因此在这种情况下,默认值就是false。另一方面,至少有一filter意味着service倾向于为外部使用,因此默认值为true。

这个属性不是唯一的方式限制对其他的应用程序公开service。你也能通过权限限制能与service交互的外部实例(具体看 permission属性)。


android:icon
代表service的图标。这个属性必须设置一个对drawable resource的引用。如果没有设置,用application的icon属性 值代替。
service的icon无论是在这儿设置还是用中的icon,都是service的intent filter的默认icon (查看 the element's icon attribute)。

android:isolatedProcess
如果设置为true,service将运行在一个特殊的进程中。这个进程是从系统的剩余进程中独立出来的,没有任何它的权限。只能通过service提供的API(bingding and starting) 与其进行交互。

android: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 isused instead (see the element's label attribute).

The service's label — whether set here or by the element — is also thedefault label for all the service's intent filters (see the element'slabel attribute).

The label should be set as a reference to a string resource, so thatit can be localized like other strings in the user interface.However, as a convenience while you're developing the application,it can also be set as a raw string.

android:name
The name of the Service subclass that implementsthe service. This should be a fully qualified class name (such as," com.example.project.RoomService"). However, as a shorthand, ifthe first character of the name is a period (for example, " .RoomService"),it is appended to the package name specified in the element.

Once you publish your application, you should notchange this name (unless you've set android:exported="false").

There is no default. The name must be specified.

android:permission
The name of a permission that an entity must have in order tolaunch 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 theIntent object will not be delivered to the service.

If this attribute is not set, the permission set by the element'spermissionattribute applies to the service. If neither attribute is set, the service isnot protected by a permission.

For more information on permissions, see thePermissionssection in the introduction and a separate document,Security and Permissions.

android:process
The name of the process where the service is to run. Normally,all components of an application run in the default process created for theapplication. It has the same name as the application package. The element's processattribute can set a differentdefault for all components. But component can override the defaultwith its own process attribute, allowing you to spread yourapplication across multiple processes.

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

你可能感兴趣的:(android开发)