Managing the Lifecycle of a Service】的更多相关文章

service的生命周期,从它被创建开始,到它被销毁为止,可以有两条不同的路径: A started service 被开启的service通过其他组件调用 startService()被创建. 这种service可以无限地运行下去,必须调用stopSelf()方法或者其他组件调用stopService()方法来停止它. 当service被停止时,系统会销毁它. A bound service 被绑定的service是当其他组件(一个客户)调用bindService()来创建的. 客户可以通过一…
Managing the Lifecycle of a Service service的生命周期,从它被创建开始,到它被销毁为止,可以有两条不同的路径: A started service 被开启的service通过其他组件调用 startService()被创建. 这种service可以无限地运行下去,必须调用stopSelf()方法或者其他组件调用stopService()方法来停止它. 当service被停止时,系统会销毁它. A bound service 被绑定的service是当其他…
官方文档原文地址:http://developer.android.com/guide/components/services.html Service是应用程序组件之一,它并不提供一个用户界面,可以负责一些在后台运行时间较长的操作.其它的应用程序组件可以启动它,就算用户切换到其它的应用上面,Service还将继续在后台运行着.另外,一个组件可以绑定一个Service并与之交互,甚至可以进行进程间通信.打个比方,service可以处理网络传输,播放音乐,执行文件IO,或者与Content Pro…
服务是一个应用组件,能够在后运行耗时的操作,不提供一个用户界面.(由于不提供界面,所以能够耗时运行,和活动最大的不同).还有一个应用组件能够启动一个服务,服务会继续在后台运行及时用户切换到还有一个应用(和活动不一样,那么生命周期就有不同了).此外,一个组件能够绑定一个服务和他进行交互甚至运行进程间通信(interprocess communication (IPC)).举例,一个服务可能处理网络事务,播放音乐,运行文件或者和一个content provider交互,全部都是在后台. 一个服务本质…
Managing the Lifecycle of a Service The lifecycle of a service is much simpler than that of an activity. However, it's even more important that you pay close attention to how your service is created and destroyed, because a service can run in the bac…
1.Creating a Started Service A started service is one that another component starts by calling startService(), resulting in a call to the service's onStartCommand() method. When a service is started, it has a lifecycle that's independent of the compo…
服务是一种应用组件,它可以在后台执行耗时的操作,它是没有用户界面的.其它的应用组件都可以开启一个服务,服务开启后,即使用户离开了应用,服务仍然可以在后台运行.此外,绑定到服务的组件可以与服务进行交互,甚至执行跨进程的通信(IPC).例如,服务可以处理网络事务,播放音乐,执行文件I/O操作,或者和内容提供器进行交互,这一切的一切都是在后台运行的. 从本质上说,服务可以有两种形式: started:当某个应用组件(例如activity)调用了 startService() 方法,那这个服务就是"st…
这几天,有同学问到为什么在 ASP.NET MVC 应用中,无法在 .ASMX 中使用 NInject 进行注入. 现象 比如,我们定义了一个接口,然后定义了一个实现. public interface IMessageProvider { string GetMessage(); } 定义一个接口的实现. public class NinjectMessageProvider : IMessageProvider { public string GetMessage() { return "T…
service的生命周期,从它被创建开始,到它被销毁为止,可以有两条不同的路径: A started service 被开启的service通过其他组件调用 startService()被创建. 这种service可以无限地运行下去,必须调用stopSelf()方法或者其他组件调用stopService()方法来停止它. 当service被停止时,系统会销毁它. A bound service 被绑定的service是当其他组件(一个客户)调用bindService()来创建的. 客户可以通过一…
首先要明白需要的情景,然后对三种方式进行选择: (一)可以接收Service的信息(获取Service中的方法),但不可以给Service发送信息 (二) 使用Messenger既可以接受Service消息,也可以发送Service消息.但是无法调用Service中的方法.因为利用Message,所以不用担心并发 Extending the Binder class If your service is private to your own application and runs in th…