使用 stopService() 时无法停止Service
使用unbindService() 时 ,会关闭应用程序,再停止Service (不是我要的)。
我需要的效果:应用程序存在且能够关闭Service
需要的效果是 :
点击 RadioButton(开启服务)在后台一直运行即使应用关闭
点击 RadioButton(关闭服务)无论应用是否停止、关闭。Service关闭
使用 stopService() 时无法停止Service
使用unbindService() 时 ,会关闭应用程序,再停止Service (不是我要的)。
我需要的效果:应用程序存在且能够关闭Service
需要的效果是 :
点击 RadioButton(开启服务)在后台一直运行即使应用关闭
点击 RadioButton(关闭服务)无论应用是否停止、关闭。Service关闭
activity 通过bindservice 与这个services进行绑定后,activity 可以获取 services 中的返回的内部类Binder 对象,该Binder implement必须实现一个自己定义的接口(方法),然后这个方法在services中具体实现为stopself(),这样就可以让ativity通过binder调用自己定义的接口(方法)控制service 关闭