Android Question Can Android restart my app ?

advansis

Active Member
Licensed User
Longtime User
Hi guys, in some versions od Android 10 (Samsung A20), I have this problem:

1) I start my application (from the icon)
2) Do the login (simply providing user and password strings) and then access work Activities
3) Press the HOME button and execute other apps (just one or two)

at this point:
1) Returning inside my app by "Task Manager" --> my app is still working where I left it
2) Launching the app by its icon --> the app seems to restart and returns to Login Activity (and I DON'T WANT THIS TO HAPPEN)

Have you ever faced this behaviour?
Thanks
 

DonManfred

Expert
Licensed User
Longtime User
once the user is logged in you should remember its state in starterservice.
When the app restarts at main you can check the state and, if already logged in, skip the loginscreen.

Sounds like the way Android works. I don´t see anything problematic in your description.
 
Upvote 0

advansis

Active Member
Licensed User
Longtime User
once the user is logged in you should remember its state in starterservice.
When the app restarts at main you can check the state and, if already logged in, skip the loginscreen.

Sounds like the way Android works. I don´t see anything problematic in your description.

@DonManfred, The problem is that if my user is inserting data or performing a multi-step task, and the phone rings, his data are lost...
I already have my global variables in services and classes and I use an heavy database (sqlite), I can check if user is logged in and a lot of other things...
Are android-apps supposed to re-run the main activity instead of continuing the running one? I don't know, but this behaviour doesn't happen in my Android-8 phone, in another Android-7 Tablet and in my daughter's Android-10 phone: it happens only in this case, as I know.
 
Upvote 0

advansis

Active Member
Licensed User
Longtime User
Did you try to use the StateManager - Helps managing Android applications settings and state to save and restore value's via Activity_Pause and Activity_Resume.
Thank you. I know StateManager and usually use it when I want to call the same activity with multiple context or to preserve data after orientation change.
Following my "forma mentis", I prefer, if possible, to understand the causes (and I don't know why the behaviour is different), then I will limit the effects (using State Manager).
I used State Manager to retrieve data of the "current" activity. In this case is more difficult because the current activity is reset (to main): I can't believe I must save the name of each activity I open...
Have a nice day!
 
Last edited:
Upvote 0

MicroDrie

Well-Known Member
Licensed User
I get the impression that StateManager could help to save the user input when the app goes in a background mode and restore the user input when it resume normal operation.
 
Upvote 0

Guru2020

Member
Hi guys, in some versions od Android 10 (Samsung A20), I have this problem:

1) I start my application (from the icon)
2) Do the login (simply providing user and password strings) and then access work Activities
3) Press the HOME button and execute other apps (just one or two)

at this point:
1) Returning inside my app by "Task Manager" --> my app is still working where I left it
2) Launching the app by its icon --> the app seems to restart and returns to Login Activity (and I DON'T WANT THIS TO HAPPEN)

Have you ever faced this behaviour?
Thanks

Is it related to PowerSave mode that background tasks killed aggressively?
 
Upvote 0

advansis

Active Member
Licensed User
Longtime User
Is it related to PowerSave mode that background tasks killed aggressively?
It is the first thing I checked, but in this case, why opening the app by task manager, the app restores from where was left?
 
Upvote 0
Top