Android Question ProgressDialogShow2("text", False) is cancelled when the app goes in background

Alessandro71

Well-Known Member
Licensed User
Longtime User
I'm displaying ProgressDialogShow2("text", False) while performing a somewhat lenghty operation (sending some data over the net), to notify the user there's something going on, and more important, to prevent him from pressing some other buttons.
this works fine if the user is polite and just waits for the task to complete.
some users are less patient and tap the Android task list button to switch to other apps.
when they get back to my app, the ProgressDialog is vanished, even if the code flow has not yet reached the ProgressDialogHide statement, causing the user to play with the app while the task is still running.
is there a way to prevent a ProgressDialog to vanish if going to background?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Use B4XProgressDialog from XUI Views:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ProgressDialog As B4XProgressDialog
End Sub

Public Sub Initialize
End Sub

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

Private Sub Button1_Click
    ProgressDialog.ShowDialog("Loading...")
End Sub
 
Upvote 0
Top