1. What is the difference between:
And:
2. Code:
a. What will it print?
b. Will it cause a stack overflow?
c. What will happen if we rotate the device?
3. What is the output of:
4.
Which steps does the user need to do in order to print: "Can you print this one?" ?
B4X:
Sub Activity_Create(FirstTime As Boolean)
For Each link As String In Array("https://www.google.com", "https://www.bing.com", "https://www.duckduckgo.com")
Download(link)
Next
End Sub
Sub Download(link As String)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(link)
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
End Sub
And:
B4X:
Sub Activity_Create(FirstTime As Boolean)
For Each link As String In Array("https://www.google.com", "https://www.bing.com", "https://www.duckduckgo.com")
Dim j As HttpJob
j.Initialize("", Me)
j.Download(link)
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
Next
End Sub
2. Code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Counter(1)
End Sub
Sub Counter(i As Int)
Log(i)
Sleep(1000)
Counter(i + 1)
End Sub
a. What will it print?
b. Will it cause a stack overflow?
c. What will happen if we rotate the device?
3. What is the output of:
B4X:
Sub Activity_Create(FirstTime As Boolean)
SingleStepEachTime
For i = 1 To 10
Log("ActivityCreate: " & i)
CallSubDelayed(Me, "SingleStepCanProceed")
Wait For ActivityCreateCanProceed
Next
Log("ActivityCreate finished")
End Sub
Sub SingleStepEachTime
For i = 1 To 10
Log("SingleStepEachTime: " & i)
Wait For SingleStepCanProceed
CallSubDelayed(Me, "ActivityCreateCanProceed")
Next
Log("SingleStepEachTime finished")
End Sub
4.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Wait For Activity_Resume
Log("Caught here!")
End Sub
Sub Activity_Resume
Log("Can you print this one?")
End Sub