Android Question Starter and CallSubDelayed

luke2012

Well-Known Member
Licensed User
Longtime User
Hi to all,
I'm trying to get the input from the user within the Starter (Service_Create).
My target is to ask to the user the account to use and than use it within the Starter (see Other code....")

The problem is that the Starter code continue without wait the inputlist (DialogResponse) and the code after the CallSubDelayed (Main, "ChooseAccount") doesn't have the SelectedAccount value because the result from the inputlist isn't available. Any solution to this?

Thanks in advance for your reply.

B4X:
Sub Process_Globals
    Public SelectedAccount As String
end sub

'Starter
Sub Service_Create
    CallSubDelayed (Main, "ChooseAccount")
    log (main.SelectedAccount)
    
    'Other code that use SelectedAccount value...
End Sub

'Main
Sub ChooseAccount
   
    Private UserAccounts As List
    UserAccounts.Initialize
    UserAccounts.Add("account1")
    UserAccounts.Add("account2")
    UserAccounts.Add("account3")
   
    Private SelIndex1 As String = InputList(UserAccounts, "Login", 0)

    If SelIndex1 <> DialogResponse.CANCEL Then
        ToastMessageShow(UserAccounts.Get(SelIndex1), True)
        SelectedAccount = UserAccounts.Get(SelIndex1)
    End If
   
End Sub
 
Top