Question about process globals and services

kolbe

Active Member
Licensed User
Longtime User
Do process globals that are declared in services get re-declared if the services crashes and is recreated? The activity stays running. It is just the service that crashes, I don't mean stops but crashes and gets recreated. I need to know if the data in these variables in this case is lost.

On that note is there a difference and what is the difference if there is, in declaring process globals in the activity vs. a service?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
When a service crashes, the whole process is terminated (including the activities). This means that the variables will be reinitialized when the service is recreated.

On that note is there a difference and what is the difference if there is, in declaring process globals in the activity vs. a service?
No.
 
Upvote 0

kolbe

Active Member
Licensed User
Longtime User
When a service crashes, the whole process is terminated (including the activities). This means that the variables will be reinitialized when the service is recreated.

Once again thanks for the quick responses.

So... I have a service running and its associated activity, the service is scheduled start again but before it is done it crashes. This terminates the activity as well. When the service starts again as scheduled (or is this scheduling lost when the process is terminated) it will also recreate the activity?? How would it know about the activity?

From the logs I get the impression as well that android tries to automatically recreate crashed services... I'm just not sure of why/how this is happening and the affect on the activity.
 
Upvote 0

kolbe

Active Member
Licensed User
Longtime User
The problem has to do with the IOIO library and the possibility of loosing the Bluetooth connection to the IOIO board. There is still a remote chance that a service will call the board, to periodically collect data, and that in the time between I've checked for a valid connection and the call to the board is made, the connection has dropped. In this case my best bet is to try to catch the exception and recreate the service.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…