I understand that if I want the service to start, even if nothing is limited to this, I must first start it using startService (Intent i).
My question is: WHAT IF I want to bind to a service right after it starts, will the following code guarantee that the service is created using startService ()?
Static method in a service class:
public static void actStart(Context ctx) {
Intent i = new Intent(ctx, BGService.class);
i.setAction(ACTION_START);
ctx.startService(i);
}
Binding Activity:
BGService.actionStart(getApplicationContext());
bindService(new Intent(this, BGService.class), serviceConnection, Context.BIND_AUTO_CREATE);
source
share