位置: 编程技术 - 正文

Services 翻译第一集(public services翻译)

编辑:rootadmin

推荐整理分享Services 翻译第一集(public services翻译),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:servers翻译,service information翻译,翻译server,serviced翻译,services的翻译,翻译server,services的翻译,serviced翻译,内容如对您有帮助,希望把文章链接给更多的朋友!

原文地址: THIS DOCUMENTThe BasicsDeclaring a service in the manifestCreating a Started ServiceExtending the IntentService classExtending the Service classStarting a serviceStopping a serviceCreating a Bound ServiceSending Notifications to the UserRunning a Service in the ForegroundManaging the Lifecycle of a ServiceImplementing the lifecycle callbacksKEY CLASSESServiceIntentServiceSAMPLESServiceStartArgumentsLocalServiceSEE ALSOBound Services

A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

Service是一个应用程序组件,它能够在后台执行长时间运行的操作,不提供用户接口。其它的应用程序组件能启动一个service,甚至在用户换切换到其它应用之后这个service仍然继续在后台执行。此外,一个组件能够绑定到一个service来和这个service进行交互,甚至执行进程间通信(IPC)操作。例如,一个service可能处理网络传输,播放音乐,执行文件I/O操作,或者与内容提供者(content provider)进行交互,都可以在后台完成。

A service can essentially take two forms:

一个service从本质上说能够采用两种形式:

Started被启动A service is "started" when an application component (such as an activity) starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed. Usually, a started service performs a single operation and does not return a result to the caller. For example, it might download or upload a file over the network. When the operation is done, the service should stop itself.一个service被启动,当一个应用组件(例如一个activity)通过调用startService()方法启动它。一旦启动,一个service能在后台永久的运行,甚至在启动它的那个组件被摧毁掉后。一般,一个被启动的service执行一个单一的操作,不返回任何结果给调用者。例如,service可能下载或上传一个文件到网络上。当操作完成后,这个service应当停止它自己。Bound被绑定A service is "bound" when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC). A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.一个service被绑定,当一个应用程序组件通过调用bindService()来绑定它。一个被绑定的service提供一个c/s接口,这个接口允许组件与service进行交互,发送请求,获得结果,甚至通过IPC跨进程这样操作。一个被绑定的service运行的时间周期与绑定它的组件一样。一次可以多个组件绑定这个service,但是当所有的组件都解绑这个service后,该service才会被摧毁。Services 翻译第一集(public services翻译)

Although this documentation generally discusses these two types of services separately, your service can work both ways—it can be started (to run indefinitely) and also allow binding. It's simply a matter of whether you implement a couple callback methods:onStartCommand() to allow components to start it and onBind() to allow binding.

尽管这个文档分开讨论了这两种类型的services,但是实际上你的service能够同时工作在两种方式下,service能够被启动(永久的运行)也能被绑定。这是一件很容易的事情,就看你是否实现了这两个回调方法:onStartCommand()允许组件启动它 和 onBind() 允许绑定它。

Regardless of whether your application is started, bound, or both, any application component can use the service (even from a separate application), in the same way that any component can use an activity—by starting it with an Intent. However, you can declare the service as private, in the manifest file, and block access from other applications. This is discussed more in the section about Declaring the service in the manifest.

不管你的应用组件是被启动还是被绑定或两者都有,任何应用组件都能够使用这个service(甚至从另一个应用使用这个service),同样的方式,任何组件能使用一个activity-通过Intent启动它。不管怎么样,你能声明一个service是私有的,在manifest文件,阻止其它应用调用。更多内容请看Declaring the service in the manifest.

Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work. By using a separate thread, you will reduce the risk of Application Not Responding (ANR) errors and the application's main thread can remain dedicated to user interaction with your activities.

注意:一个service运行在拥有它的进程的主线程中--这个service不会创建它自己的线程,也不会运行在一个独立的进程中(除非你指定一个进程)。意思是说,如果你的service将要做任何CPU密集的工作或者阻塞操作(例如播放MP3或网络任务),你应该在service内创建一个新的线程来做那些工作。通过使用独立的线程,你将会减少应用程序无响应错误(ANR)的风险,而且应用的主线程还能够致力于用户与你activaty的交互。

自定义view_开关按钮 注:源自传智播客视频教程现整理此案例,以供日后自己或大家学习、参考:android自定义view实现的简单demo实现效果:1.点击按钮可以改变开关的状态2.

自定义ListView适配器继承BaseAdapter 在开发中,我们经常使用到ListView这个控件。Android的API也提供了许多创建ListView适配器的快捷方式。例如ArrayAdapter、SimpleAdapter和SimpleCursorAdapter等。但你

android(7) 界面的实现 一.界面的实现:看了别人的源码从而又完善了一下,这种界面实现起来还是不麻烦的(要源码的留下邮箱,我给你们发)。效果图:主界面:publicclas

标签: public services翻译

本文链接地址:https://www.jiuchutong.com/biancheng/384341.html 转载请保留说明!

上一篇:android自定义gridview,根据item自动适应高度(Android自定义标签选择面板,自定义ViewGroup)

下一篇:自定义view_开关按钮(自定义view ondraw)

  • 资源税和增值税销售额不一致
  • 专利年费滞纳金计入什么科目
  • 利润表中的资产减值损失包括哪些
  • 房租收入怎么报税
  • 利润分配在利润表里填哪一项
  • 主营业务收入和销售收入
  • 预缴增值税项目编号填写错误怎么办
  • 股息红利增值税和企业所得税
  • 房产税的原值是如何确定的
  • 闲置设备折旧企业所得税税前扣除
  • 工伤医疗费用个人社保卡支付找谁报销
  • 房地产企业土地使用税
  • 个人转让商铺个人所得税核定征收
  • 应发工资包含扣款吗
  • 个人账户转公司账户需要交税吗
  • 企业销售现金折扣
  • 废品损失一般不由本月生产的产品成本负担
  • 房屋租赁发票需要备注吗
  • 收的标书收入增值税多少
  • 企业设备安装发票税率为多少?
  • 小规模代扣代缴个税会计分录
  • 一般纳税人具备的资格需要哪些条件
  • 个体工商户生产经营所得税税率表2021
  • 地下车库是否需要设置消防电梯?
  • 公司办事处人员配置标准最新
  • 人工工资应该计什么科目
  • 应收款项核销的原因
  • win10专业版19042.630
  • macqq怎么查看删除好友
  • 财务决算报表是谁编制的
  • php字符串型数据的定义方式
  • 拍卖公司收入计入什么分录
  • nalntsrv.exe - nalntsrv是什么进程 有什么用
  • 软件能否成为无线网
  • 蓝桥杯等级
  • 固定资产清理的借贷方向表示什么
  • php使用while循环计算1到100的和
  • 酒类销售企业广告宣传语
  • 建筑工程房屋租赁费属于什么费用
  • 销售方红字发票的账务处理?
  • php进行批量任务分类
  • 归还本金和利息的分录
  • 工程实践指的是
  • 小程序项目开发流程
  • service iptables save
  • 浅谈php中静态方法的应用
  • find命令结果怎么导出到文本
  • 房租税务局代增值税发票 税点
  • 高效快速编制会计分录如何做?
  • 新公司成立需要刻哪些章
  • 现金流量表中的现金流量包括哪些
  • 进口货物如何支付外汇
  • 商家的这些行为对消费者的购买行为有什么影响
  • 行政事业单位职工工伤有哪些待遇
  • 政府会计工资代扣工会会费
  • 建筑公司挂靠单位的财务处理是?
  • 融资租赁中承租人的义务
  • 企业为员工代缴社保怎样在网上申报
  • 员工社保,个税怎么计算
  • xp系统电脑开机密码忘记了
  • win2003r2企业版密钥
  • win8系统如何查看电脑内存
  • ubuntu搭建nginx服务器教程
  • win8 开机
  • win7系统玩暗黑2怎样全屏
  • windows xp系
  • .mcp是什么文件
  • 安装win8.1一直卡着不动
  • linux在云计算中的使用
  • windows 10预览版
  • opengl gltranslatef
  • javascript教程完整版
  • Node.js中的construct
  • firefox margin-top失效的原因与解决办法
  • python3m
  • jquery fadein 源码
  • android设计模式的应用场景
  • 吉林省残疾人保障金减免政策
  • 广东税务局查验
  • 长春国税局科员工资是多少
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设