Android API文档翻译——Service

概述:

声明一个Service(或其子类)组件。与Activity不同的是,Service是非可见的。他们常用于实现长驻后台的操作或为其他Application提供类似WebService的交互接口。

所有的Service必须在manifest配置文件中通过<service>标签来声明。如果没有声明的话,则不会在system中看到,而且永远不能被运行。

 

参数:

android:enabled

  Service是否能被系统初始化,默认为true。(具体什么叫被系统初始化,还需要研究)

  <application> and<service> 的enable属性必须都为true,该Service才能被系统初始化,缺一不可。 当然,默认情况下就是true,所以一般也不用设置。

 

android:exported

标识该组件是否可以被其他应用程序调用,或者与其交互。

该参数的默认值取决于<service>是否包含<intent-filter>,如果不包含,则默认值为false,反之则为true。

这个参数并不是唯一可以限制Service入口的参数。你也可以使用permission权限控制来达到相同的目的。

 

android:icon

说白了就是在进程菜单中显示该Service的Logo。

 

 

android:label

   说白了就是在进程菜单中显示该Service的Name。

 

android:name

    就是你的implements了Service类的实现类。他既可以是一个类全名,也可以只包含类名。注意:该属性没有默认值,必须被明确声明。

 

android:permission

    标识此Service的调用权限,如果没有设置,则默认使用<application>的权限设置。

 

android:process

标识该Service将运行在哪个进程中。一般来说,所有的组件都会默认运行在创建它们的Application中,名称跟包名相同。(设置为system是什么意思?)

If the name assigned tothis attribute begins with a colon (':'), a new process, private to theapplication, 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 ina global process of that name, provided that it has permission to do so. Thisallows components in different applications to share a process, reducingresource usage.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值