I am starting a service like this:
it works 100%. But when I "unbind" the service with...
.....and then quite and restart the app the scanner wont work. I have logged various variables and scannerservice is definitely not null upon a restart of the app.
If I set scannerservice to null when quitting the app and then restart the app then it works. My question is - if I set scannerservice to null when quitting the app, does it actually stop/kill the service that I have started before?
B4X:
public void Initialize(BA paramBA, String EventName) {
this.eventName = EventName.toLowerCase(BA.cul);
ba = paramBA;
conn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
//Bind successfully
scanservice = ((IMyBinder) iBinder).getService();
if (ba.subExists(eventName + "_onbind")) {
ba.raiseEvent2(ba, false, eventName + "_onbind", true, new Object[] {});
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
BA.Log("scanservice disconnected");
scanservice = null;
//ba.raiseEventFromDifferentThread(ba.applicationContext, null, 0, eventName + "_onunbind", true, new Object[] {});
}
};
intent = new Intent(ba.context,ScanService.class);
ba.context.bindService(intent, conn, 1);
}
it works 100%. But when I "unbind" the service with...
B4X:
ba.context.unbindService(conn);
If I set scannerservice to null when quitting the app and then restart the app then it works. My question is - if I set scannerservice to null when quitting the app, does it actually stop/kill the service that I have started before?