Android Question Application resume

obscure

Member
Licensed User
Longtime User
Hi there!

I ran into a problem.
The situation is as follows:

1. The application consists of several activities
2. The first activity holds some global variables, which are accessed from
within the other activities using Main.variableName
3. User selects an entry in the main activity, which pauses it and starts
a second activity to edit the selected entry
4. The second activity is still running, user doesn't do anything for a
while, the device turns off the screen and after a while the device goes
into sleep
5. After several minutes the user decides to reactivate his device, the second
activity resumes, tries to access the global variable which is inside the main
activity and the application crashes because obviously Android decided to kill
the main process meanwhile

Any ideas to overcome this issue?

Thanks!

cheers,
obscure
 

DonManfred

Expert
Licensed User
Longtime User
USe Statemanager
 
Upvote 0

obscure

Member
Licensed User
Longtime User
Thanks Manfred.
Unfortunately that's not an option here.
I was thinking of something different but don't know if it's possible.
Is there a function I'm not aware of, that can check for the presence of the main
activity and if it's not present, exit and restart the whole application instead of
resuming from another activity?
Or does someone have any other idea?

cheers,
obscure
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
'IsPaused' will tell you if an Activity is paused or not

B4X:
If IsPaused(Main) = False Then CallSub(Main, "RefreshData")

See here. Its about Activity life cycles. You will get a Pause event fired before you app is killed.

Also look at this. its about service modules and there lifetime.
 
Last edited:
Upvote 0
Top