This is my flow :
1. Main ---> Process Job
2. in Main, Klik button to call Activity2 (Main activity in processing job....)
3. Activity2 open, but back again to Main activity.
How to handle it?
As @DonManfred said, move that job to service and after the job is done send the data back to activity for processing. Like this,
B4X:
Public Sub LoadData() As ResumableSub
Dim j As HttpJob
Dim Data() As Byte
j.Initialize("", Me)
j.Download("URL")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Data = j.GetString.GetBytes("UTF8")
If Not(IsPaused(Main)) Then CallSubDelayed2(Main,"ProcessData",Data)
End If
j.Release
Return j.Success
End Sub
As @DonManfred said, move that job to service and after the job is done send the data back to activity for processing. Like this,
B4X:
Public Sub LoadData() As ResumableSub
Dim j As HttpJob
Dim Data() As Byte
j.Initialize("", Me)
j.Download("URL")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Data = j.GetString.GetBytes("UTF8")
If Not(IsPaused(Main)) Then CallSubDelayed2(Main,"ProcessData",Data)
End If
j.Release
Return j.Success
End Sub
As @DonManfred said, move that job to service and after the job is done send the data back to activity for processing. Like this,
B4X:
Public Sub LoadData() As ResumableSub
Dim j As HttpJob
Dim Data() As Byte
j.Initialize("", Me)
j.Download("URL")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Data = j.GetString.GetBytes("UTF8")
If Not(IsPaused(Main)) Then CallSubDelayed2(Main,"ProcessData",Data)
End If
j.Release
Return j.Success
End Sub
Public Sub ProcessData(data() As Byte) As ResumableSub
Dim StringData As String = BytesToString(data,0,data.Length,"UTF-8")
Log(StringData)
End Sub
'if you are downloading json data from httpjob then use this
Public Sub ProcessData(data() As Byte) As ResumableSub
Dim StringData As String = BytesToString(data,0,data.Length,"UTF-8")
Dim json As JSONParser
json.Initialize(StringData)
Dim OriginalData As List = json.NextArray
Log(OriginalData)
End Sub
Public Sub ProcessData(data() As Byte) As ResumableSub
Dim StringData As String = BytesToString(data,0,data.Length,"UTF-8")
Log(StringData)
End Sub
'if you are downloading json data from httpjob then use this
Public Sub ProcessData(data() As Byte) As ResumableSub
Dim StringData As String = BytesToString(data,0,data.Length,"UTF-8")
Dim json As JSONParser
json.Initialize(StringData)
Dim OriginalData As List = json.NextArray
Log(OriginalData)
End Sub