Android Question B4X CloseRequest issue

Alrikh

Member
Hello everyone,
i'm new of B4A/B4X in general ^^

I have tried create a simple app whit an splash screen and after 2 sec. go in login page like:

Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")

vLogin.Initialize
B4XPages.AddPage("viewLogin", vLogin)

CallSubDelayed(Null, "ShowLogin")

End Sub
...
Private Sub ShowLogin
Sleep(2000)
B4XPages.ShowPageAndRemovePreviousPages("viewLogin")
End Sub

in a 2nd page, i try manage the exit whit this logic:

Public Sub B4XPage_CloseRequest As ResumableSub
Dim sf As Object = xui.Msgbox2Async("Sicuro di voler chiudere l'applicazione?", "Attenzione", "Si", "", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Return True
End If
Return False
End Sub

when i press back button incur in an exception..
Sub B4XPage_CloseRequest was not found

obviously if i put the exit logic in the main page all works fine, but if i want continue thou this way, which event i must use?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

This is not needed:
B4X:
CallSubDelayed(Null, "ShowLogin")
Replace with:
B4X:
Sleep(0)
ShowLogin

when i press back button incur in an exception..
Sub B4XPage_CloseRequest was not found
Please upload the project (Ctrl + Click the link at the top of B4XMainPage).
 
Upvote 0

Alrikh

Member
Hello!
Today after restart of B4A, all works with your suggestion and without :S

but if i use sleep(0) the app not show any splash screen

thanks for your time Erel
 

Attachments

  • Project.zip
    248.4 KB · Views: 136
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your code is equivalent to:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    vLogin.Initialize
    B4XPages.AddPage("viewLogin", vLogin)
    Sleep(2000)
    B4XPages.ShowPageAndRemovePreviousPages("viewLogin")
End Sub

Note that your app crashes on my device as it needs the WRITE_SETTING permission. I'm not sure what you are trying to do with the screen time, but it is probably better not to.
 
Upvote 0

Alrikh

Member
Your code is equivalent to:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    vLogin.Initialize
    B4XPages.AddPage("viewLogin", vLogin)
    Sleep(2000)
    B4XPages.ShowPageAndRemovePreviousPages("viewLogin")
End Sub

Note that your app crashes on my device as it needs the WRITE_SETTING permission. I'm not sure what you are trying to do with the screen time, but it is probably better not to.
yes i know, but i need the device remain active over all night, so i have supposed one action from user every 20 min.
 
Upvote 0
Top