Bug? Main Activity randomly recreated

ThePlankton

Member
Licensed User
EDIT #2

I've narrowed this further. This has nothing to do with app life cycle.

This can be reproduced with a single line of code. Main Activity starts Activity #2, then hit the home button and tap the app icon. It'll reload the Main activity and not resume where you left off

THIS ONLY HAPPENS AFTER APP INSTALL/UPDATE

If the app is stopped or device rebooted it then works as expected.

Issue being after my users pull an app update they just start using it like they should be able to.

I can reproduce this using B4A-Bridge

Anyone have any experience with this?

------------------------------------------------------------------------------------------

EDIT: I believe I know what's happening now but still not clear on a solution.

Lets say the user starts the app from the home screen icon. Main activity loads. User then navigates to Active B then to Activity C.

User then hits the home button and performs some unrelated task. When wanting to return to my app they tap the icon on the home screen again.

This does not resume the app. It relaunches the Main activity. IMO it should resume the app with the last activity the user was on but it doesn't.

If the user resumed the app from the Recent apps menu it resumes as expected.

------------------------------------------------------------------------------------------

I'm getting nowhere trying to track this down.

What would cause the Main activity to be randomly recreated? I'm not calling the Main activity anywhere in code.

You can see in my log:

08/09/2022 07:20:36.524 - In MessageSender.Service_Destroy
08/09/2022 07:29:16.011 - In Main Activity_Create <- Main activity is recreated. App was already running and multiple activities already loaded on top of Main
08/09/2022 07:29:16.040 - In MAIN.Activity_Resume
08/09/2022 07:29:16.063 - Battery optimization ignored: true
08/09/2022 07:29:16.115 - In TerminalActivities Activity_Resume <- I automatically reload the activities that the user already had started
08/09/2022 07:29:16.184 - In CityActivities Activity_Resume <- Another one
08/09/2022 07:29:18.935 - In Main Activity_Create <- BAM its created again!
08/09/2022 07:29:18.963 - In MAIN.Activity_Resume
08/09/2022 07:29:18.986 - Battery optimization ignored: true

Like I said I'm not calling the main activity anywhere in code. What would cause this? Any help would be appreciated. I have this app installed on 5000 devices and its causing serious production issues
 
Last edited:

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Take a look at this.


Note in Activity_create the line,
"Destroyed by OS for memory reclamation" do you check the FirstTime flag?

and also Erels tutorial.

Without seeing the code, cannot be an more helpful.
 
Top