Android Question b4xpages close the app

Addo

Well-Known Member
Licensed User
Longtime User
how to properly close the entire app of b4xpages ?

currently, I do something like this

B4X:
private Sub B4XPage_CloseRequest As ResumableSub

Dim sf As Object = xui.Msgbox2Async("Close?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
    B4XPages.ClosePage(Me)
    Return True
End If
Return False

End Sub

but this won't close the app instead it sends it to the background! what exactly needed to immediately close the b4xpages app?
 

TILogistic

Expert
Licensed User
Longtime User
how to properly close the entire app of b4xpages ?

currently, I do something like this

B4X:
private Sub B4XPage_CloseRequest As ResumableSub

Dim sf As Object = xui.Msgbox2Async("Close?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
    B4XPages.ClosePage(Me)
    Return True
End If
Return False

End Sub

but this won't close the app instead it sends it to the background! what exactly needed to immediately close the b4xpages app?
see:

The three most important things regarding the B4XPage classes are:
  1. The page classes are 100% regular classes. They don't have a special life cycle and you can do whatever you like with them. There are some B4XPages events but they don't affect the state of the class itself. This is not the case with activity modules.
  2. The page classes are never paused. Nothing special happens when a page is no longer visible or when the app moves to the background. Eventually of course, the whole process will be killed when the app is in the background.
  3. The page classes are never destroyed separately. The class global variables and views state will never be reset (until the process is killed).

The question is:

How do I remove a page class?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
or use:

1613512945811.png
 
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
How then, without using ExitApplication, do you remove the application from the users view to at least give the user the impression it has closed?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
How then, without using ExitApplication, do you remove the application from the users view to at least give the user the impression it has closed?

or Activity.finish it is recommended

Whichever method you use, Android will leave the app in memory (but not running) for as long as it can. This is to be more efficient. When you come back to the app, if it's still in memory, Android can run it again right away; if it isn't still in memory, then Android has to spend time and energy loading the app from storage again.

In old Android versions, apps left in memory in the background this way were included in the list of "running apps". This is a little confusing for users - it makes people think the app is really still running - so newer versions call these apps "cached background processes", to make it clear they're only cached, not running.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Don't know if this can be of any help. It was a function I used in an old app of mine:

B4X:
Sub RemoveActivityFromForeground
    
    '*** Below code moves the task containing this activity to the back of the activity stack.***
    '*** It's a quick way to remove your activity, more or less like "bring to back"
    Dim jo As JavaObject
    jo.InitializeContext
    jo.RunMethod("moveTaskToBack", Array(True))
    '********************************************************************************************
    
End Sub
 
Upvote 0
Top