本帖最后由 Daniel_Cao_ 于 2010-06-29 14:16:47 编辑

解决方案 »

  1.   

    service一般用于进程间通信(ipc)。比intent更加高效
      

  2.   

    local service并不是service的主要作用,从这个意义来说local service和thread作用差不多,可能就是比thread更封装了一层。
      

  3.   


    希望是这样~  否则真搞不懂android这么做为了啥...hehe 
      

  4.   


    “比intent更加高效” 是什么意思,不太理解,希望仁兄解释一下:)
      

  5.   

    local service并不是service的主要作用,
       一般直接用thread
      

  6.   

    不太明白楼主表达的意思,service 和线程 本就是两个概念另外对于如果调用service方法,这个是工作在调用线程中的。service只是提供了这方面的服务。
      

  7.   

    楼主说的是服务机制吗,我只用过简单的服务机制,它可以选择执行的用户权限,你可以调用一个服务以root的权限去操作设备,用thread有这样的权限吗?
      

  8.   

    你的意思我明白,  service是工作在调用线程中的,要想实现不block调用线程就得在service中启用新线程。 为什么要这么麻烦呢,直接启用新线程就好了,从结构上也是提供一种服务。当然我说的这些都是指localservice。
    比较同意  aclongking的看法。
      

  9.   

    这几天终于搞清楚local service与thread应用场合的区别。 为了不误导浏览帖子后来者。在此澄清1、local service 与 thread 不是统一级别的概念。
    2、一般service的具体操作都是由单独的一个线程处理(典型的是由 HandleThead处理,这样和主线程就可以通过handler.sendmessage 传递数据)
    3、启动service后,如果应用中的所有acitvity都推出(按返回键),这时,应用程序还会存在,不过是以service的形式存在。 acitivity随时可能被系统destroy而service不会。 这样local service 就有改变程序生命周期的左右。这就是service的一大作用。另外, remote service 和local service 提供的功能基本一致。 不同在于 remote service 是单独一个进程。要通过ipc 与client传递数据。
      

  10.   


    =================================================================
    1、local service 与 thread 不是统一级别的概念。   这句话没看明白
      

  11.   

    我觉的Service能用THread代替,我试过很多方法了。不知道各位有什么见解,如果想讨论一下可以发我邮箱
    [email protected]
      

  12.   

    Thread 不会改变activity的生命周期。 程序会在不知情的情况下,被系统kill掉
      

  13.   

    sorry 笔误: 1、local service 与 thread 不是同一级别的概念
      

  14.   

    Thus a Service itself is actually very simple, providing two main features:    * A facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application). This corresponds to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it.
        * A facility for an application to expose some of its functionality to other applications. This corresponds to calls to Context.bindService(), which allows a long-standing connection to be made to the service in order to interact with it. 
      

  15.   

    还是有点不明白,希望楼主解释一下!
    首先,我知道Thread和service不是一个概念,但是他们有共通点。我的问题就是,在线程方面,Thread和Service那个更好?各自有什么优缺点!?
    比如,在一个socket联网的程序中,是用Thread好一些还是用service好一些?