I need non-killable service.
At first, I tried to restart the Starter service using StartServiceAtExact ("", DateTime.Now + 1000, True) .
Works, but appears a red line in the log file - The Starter service should never be started from a receiver.
As I understand, it's neccessary to start another service (not very comfortable).
That's why I tried inline Java code (found on stackoverflow)
Also works.
So, first question - is it safe ? I read some discussions and didn't see that it's not allowed to restart itself.
Another question.
I tried also to use Service_TaskRemoved in additional service module.
B4A doesn't include Sub Service_TaskRemoved in bas file. But generated java-code includes
Why (false) ? B4A doesn't want TaskRemoved in services other than Starter ?
At first, I tried to restart the Starter service using StartServiceAtExact ("", DateTime.Now + 1000, True) .
Works, but appears a red line in the log file - The Starter service should never be started from a receiver.
As I understand, it's neccessary to start another service (not very comfortable).
That's why I tried inline Java code (found on stackoverflow)
B4X:
PendingIntent service = PendingIntent.getService (getApplicationContext (), 0, new Intent (getApplicationContext (), starter.class), PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager) getSystemService (Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 1000, service);
So, first question - is it safe ? I read some discussions and didn't see that it's not allowed to restart itself.
Another question.
I tried also to use Service_TaskRemoved in additional service module.
B4A doesn't include Sub Service_TaskRemoved in bas file. But generated java-code includes
B4X:
public void onTaskRemoved(android.content.Intent rootIntent) {
super.onTaskRemoved(rootIntent);
if (false) processBA.raiseEvent(null, "service_taskremoved");
}
Why (false) ? B4A doesn't want TaskRemoved in services other than Starter ?