Bug? App spontaneously restarting?

ThePlankton

Member
Licensed User
I have a lot of logging in the app I have installed on about 5000 Honeywell CT60 devices. I log Activity_Create, Activity_Resume and Activity_Pause to help in following the flow of the app in the log file.

I cannot explain what I'm seeing in the log file. It appears as though the app just spontaneously restarts at different points of execution

Another really odd thing is after it "restarts" the Activities (at least the one showing at the time of restart) does not get recreated when the user navigates to it, it Resumes from it previous state. Any data entered into the fields on the activity before the restart is still there

ie:
08/04/2022 09:34:57.245 - Done DeliverySignature Activity_Create
08/04/2022 09:35:33.391 - In Main Activity_Create
08/04/2022 09:35:33.423 - In MAIN.Activity_Resume

another:
08/04/2022 08:32:17.083 - Successfully sent message : 1659616336507265.msg
08/04/2022 08:32:17.094 - In MessageSender.Service_Destroy
08/04/2022 08:32:41.770 - In Main Activity_Create
08/04/2022 08:32:41.808 - In MAIN.Activity_Resume

I'm at a total loss on this, any help would be appreciated.

EDIT. I just looked at another one. Restarted 14 times over his day at random points. This doesnt seem to be an actual restart of the app since the Starter service never seems to restart. Its like the MAIN activity just randomly gets recreated
 
Last edited:

agraham

Expert
Licensed User
Longtime User
If your app is going into the background to run other apps than this could well be normal Android behaviour. Android can kill Activities in the background and recreate them when brought to the foreground. This is why you need to save state in Activity_Pause and reset it in Activity_Resume. However I don't see any Activity_Pause logging in your example which is odd.

Switch to B4XPages and this should not occur.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Are you using the starter service ? If so, are you logging anything in it ? I dont see any reason why Android would kill your app then restart it. Are there many points in your app where you call Main ? You might also consider using logcat to get the systems logs from the device. I find it very helpful.
 

ThePlankton

Member
Licensed User
If your app is going into the background to run other apps than this could well be normal Android behaviour. Android can kill Activities in the background and recreate them when brought to the foreground. This is why you need to save state in Activity_Pause and reset it in Activity_Resume. However I don't see any Activity_Pause logging in your example which is odd.

Switch to B4XPages and this should not occur.
Thank you for the reply.

I was thinking it may be going into the background which would make sense but I see a lot of like the example I pasted:

08/04/2022 09:34:57.245 - Done DeliverySignature Activity_Create <- LOGS CREATE, BUT NEVER HITS RESUME BEFORE MAIN GET RE-CREATED
08/04/2022 09:35:33.391 - In Main Activity_Create
08/04/2022 09:35:33.423 - In MAIN.Activity_Resume

30s pass before the Main Create, makes me wonder if there an error popping that the user has to accept to continue. I do log Starter.Application_Error as well but theres nothing logged there.
 

agraham

Expert
Licensed User
Longtime User
From the activity lifecycle you should be getting Activity_Pause called when your activity goes into the background. You don't mention whether you see this.
You apparently have more than one activity in your app which could make things a little confusing. Are you starting Main from DeliverySignature.Activity_Create?
Restarted 14 times over his day at random points. This doesnt seem to be an actual restart of the app since the Starter service never seems to restart. Its like the MAIN activity just randomly gets recreated
What is your definition of 'restart'. Activieis in an app can be destroyed and recreated while the process is still running. Starter service is only closed when the entire process is killed.
 

ThePlankton

Member
Licensed User
Are you using the starter service ? If so, are you logging anything in it ? I dont see any reason why Android would kill your app then restart it. Are there many points in your app where you call Main ? You might also consider using logcat to get the systems logs from the device. I find it very helpful.
Thank you for the reply.
Yes I am using the Starter and logging its events as well. It appears like the app is not restarting but the Main Activity is being recreated at what seems like random points.

No where in the app do I call Main. Main serves as a login page. Once logged in all other activities stack on top and eventually finish and fall back to Main at logoff

I'll research logcat, I assume that would provide lower level logging.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Thank you for the reply.
Yes I am using the Starter and logging its events as well. It appears like the app is not restarting but the Main Activity is being recreated at what seems like random points.

No where in the app do I call Main. Main serves as a login page. Once logged in all other activities stack on top and eventually finish and fall back to Main at logoff

I'll research logcat, I assume that would provide lower level logging.
sounds like you need to use B4XPages
 

ThePlankton

Member
Licensed User
From the activity lifecycle you should be getting Activity_Pause called when your activity goes into the background. You don't mention whether you see this.
You apparently have more than one activity in your app which could make things a little confusing. Are you starting Main from DeliverySignature.Activity_Create?

What is your definition of 'restart'. Activieis in an app can be destroyed and recreated while the process is still running. Starter service is only closed when the entire process is killed.
I think I was wrong when I started this thread. Its not a restart of the app but the Main activity is being recreated
 
Top