search

Home  >  Q&A  >  body text

android - 安卓中服务与组件通信的问题

菜鸟求教:一直很疑惑一个问题,如果活动想要跟组件通信时,为什么不能

intent = new Intent(...);
startService(...);

启动服务后,然后直接调用service类中的方法?为什么一定要将活动和服务绑定(这样不是还得实现ServiceConnection类并且还要修改service类中的onBinder()方法么)
感谢您的指点迷津~

PHPzPHPz2773 days ago461

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:55:47

    Activity passes bindService to solve the problem of calling activiy and service when they are not in the same process. If it is the same process, you can directly call the method in service!

    reply
    0
  • Cancelreply