![](/img/trans.png)
[英]Service is being started but OnCreate or OnStart are not being called
[英]Service onCreate() is not being called
我有一个活动 A,单击按钮后,我正在启动另一个活动 B,在该活动中我使用bindService
启动服务,如下所示:
Intent intent = new Intent(context, RadioService.class); context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
在此期间,正在调用服务类的onCreate()
。 现在,当我关闭 BI 的onDestroy()
中的活动 B 时,将停止服务,如下所示:
context.unbindService(serviceConnection);
我面临的问题是第二次,如果我进入活动 B,则不会调用服务类onCreate()
。 为什么会这样? 我想要调用onCreate()
可以做什么。
我通过在bindService()
之前调用startService()
来解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.