Android Question How to prevent Activity_Resume to start...

OdyMiles

Member
Licensed User
Hi,
the question may sound a little bit confused...
When I start my app Activity_Resume will be executed as well even at the first time.

I have

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    haupt
End Sub

sub haupt
 ...
toastmessage...
end haupt

Sub Activity_Resume
    Msgbox("Anwendung beenden","")
    ExitApplication
End Sub
before the toastmessage is shown the Application has already been exited...

What am I doing wrong?

Thanks Chris
 

JordiCP

Expert
Licensed User
Longtime User
The only wrong thing I see is calling ExitApplication from Activity_Resume

Activity_Resume is ALWAYS called after Activity_Create (not only when coming back into life after Activity_Pause).
 
Upvote 0

OdyMiles

Member
Licensed User
Hi,
thanks for your fast reply.
Actualy, this was an example for testing reasons, since I cannot figure out how to prevent activity_Resume beeing always called immediatly...
Thanks Chris
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Why do you want to prevent it? It is how Android activities work

Read this here
Activity_Resume is called right after Activity_Create finishes or after resuming a paused activity (activity moved to the background and now it returns to the foreground).
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
You can't prevent the event from firing but you could use a variable and check it's state to decide whether or not to execute the code contained within the routine.
 
Upvote 0
Top