这是我的理解,如果我想要一个服务即使没有任何限制运行,那么它必须首先启动startService(意图我)。在bindService之前等待启动服务
我的问题是,如果我想在启动后立即绑定到服务,下面的代码是否可以保证服务是用startService()创建的?
服务类中的静态方法:
public static void actStart(Context ctx) {
Intent i = new Intent(ctx, BGService.class);
i.setAction(ACTION_START);
ctx.startService(i);
}
结合活性:
BGService.actionStart(getApplicationContext());
bindService(new Intent(this, BGService.class), serviceConnection, Context.BIND_AUTO_CREATE);
我面临同样的问题。你有没有找到决定? –
bindservice实际上等待startservice完成 – Paul