android service 运行方式有一下两种
其一:通过intent启动,走 oncreate()-->onstart()回调,销毁时走ondestory();
其二:bindService启动,走oncreate()-->onBind()回调,销毁时走onUnbind()-->ondestory()。
分析两种运行方式的控制行为
方式一:需要对service进行单独的处理,适用复杂的环境;
方式二:与activity关联,不需要考虑生命周期问题,管理方便。
本文共 274 字,大约阅读时间需要 1 分钟。
android service 运行方式有一下两种
其一:通过intent启动,走 oncreate()-->onstart()回调,销毁时走ondestory();
其二:bindService启动,走oncreate()-->onBind()回调,销毁时走onUnbind()-->ondestory()。
分析两种运行方式的控制行为
方式一:需要对service进行单独的处理,适用复杂的环境;
方式二:与activity关联,不需要考虑生命周期问题,管理方便。
转载于:https://blog.51cto.com/zilla/760380