Android Question Activity Create Automatically many times

AndroidMadhu

Active Member
Licensed User
Hello,
Activity creating automatically while running my program. Here Activity [qrActivity] restarting/creating automatically....

Below is the Log details. ...

B4X:
* Service (starter) Create *
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
mqtt_init

** Activity (main) Resume **
Activity Resume-Tracker Start
MQTT Connected
* Service (tracker) Create *
** Service (tracker) Start **
0
0
Location not initialized... Sleep a while...
Initialized---
Location not initialized... Sleep a while...
Initialized---

Panel size is unknown. Layout may not be loaded correctly.
Session_OZZGlIZuQf
* Service (httputils2service) Create *
** Service (httputils2service) Start **
JobName = JobDrvReady, Success = true
true
JobName = JobDrvOffline, Success = true
** Activity (main) Pause, UserClosed = false **
** Activity (seccode) Create, isFirst = true **
** Activity (seccode) Resume **
** Activity (seccode) Pause, UserClosed = true **
** Activity (qractivity) Create, isFirst = true **
qrActivity - Create
** Activity (qractivity) Resume **
B4A: xxxx.xxxx.xxxx
JobName = Job1, Success = true
{"arrkey":[{"sessid":"Hs3JPbiCaY"}]}
Hs3JPbiCaY
** Activity (qractivity) Pause, UserClosed = true **
** Activity (main) Resume **
Activity Resume-Tracker Start
** Service (tracker) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (qractivity) Create, isFirst = false **
qrActivity - Create
** Activity (qractivity) Resume **
JobName = Job2, Success = true
success
** Activity (qractivity) Pause, UserClosed = true **
** Activity (main) Resume **
Activity Resume-Tracker Start
** Service (tracker) Start **
JobName = JobDrvOffline, Success = true
** Activity (main) Pause, UserClosed = false **
** Activity (seccode) Create, isFirst = false **
** Activity (seccode) Resume **
** Activity (seccode) Pause, UserClosed = true **
** Activity (qractivity) Create, isFirst = false **
qrActivity - Create
** Activity (qractivity) Resume **
B4A: xxxx.xxxx.xxxx
JobName = Job1, Success = true
{"arrkey":[{"sessid":"failureDriver"}]}
Failed to login
** Activity (qractivity) Pause, UserClosed = true **
** Activity (seccode) Create, isFirst = false **
** Activity (seccode) Resume **
** Activity (seccode) Pause, UserClosed = true **
** Activity (qractivity) Create, isFirst = false **
qrActivity - Create
** Activity (qractivity) Resume **
B4A: xxxx.xxxx.xxxx
JobName = Job1, Success = true
{"arrkey":[{"sessid":"zy9Zf7HNuy"}]}
zy9Zf7HNuy
** Activity (qractivity) Pause, UserClosed = true **
** Activity (main) Resume **
Activity Resume-Tracker Start
** Service (tracker) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (qractivity) Create, isFirst = false **
qrActivity - Create
** Activity (qractivity) Resume **
JobName = Job2, Success = true
success
** Activity (qractivity) Pause, UserClosed = true **
** Activity (main) Resume **
Activity Resume-Tracker Start
** Service (tracker) Start **
JobName = JobDrvOffline, Success = true
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Activity Resume-Tracker Start
** Service (tracker) Start **


Below is my code. for "qrActivity" Activity...

B4X:
 Sub JobDone (Job As HttpJob)
Dim Query As String
Dim session As String
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)

If Job.Success = True Then
Select Job.JobName
Case "Job1"
Log(Job.GetString)
Dim JSON As JSONParser
JSON.Initialize(Job.GetString)

Dim Map1 As Map
Dim m As Map
Map1 = JSON.NextObject
Dim MenuItems As List
MenuItems = Map1.Get("arrkey")
Dim str As String
For i = 0 To MenuItems.Size - 1
m = MenuItems.Get(i)
session=m.Get("sessid")
Next
If session.IndexOf("failure")>=0 Then
Log("Failed to login")
ToastMessageShow("Failed to login",True)
sessionId=""
Activity.Finish()
StartActivity(secCode)

Else
sessionId=session
Query = "INSERT INTO session VALUES ('"& session &"')"
Main.SQL1.ExecNonQuery(Query)
Log(session)
Job2.Download("http://xx.xx.xx.xx/setDriverReady?sess=" & "driver_" & sessionId)
Activity.Finish()
StartActivity(Main)
End If
Case "Job2"
Log(Job.GetString)
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release

End Sub

Another activity from where the "qrActivity" activity has been called...

B4X:
Sub Button1_Click

securityCode=EditText1.Text
If securityCode.Length()<>6 Then
ToastMessageShow("Please enter valid code",True)
Else
Activity.Finish()
StartActivity(qrActivity)
End If

End Sub


Please advice as why qrActivity has been automatically opening/loading......
 

DonManfred

Expert
Licensed User
Longtime User
Job2.Download("http://xx.xx.xx.xx/setDriverReady?sess=&quot; & "driver_" & sessionId) Activity.Finish() StartActivity(Main)
the job will reopen qractivity when the job is ready.

You should use wait for to wait for the job to finish before you finish the activity.

You should put all the networking into the starter service.

Better solution is to switch to B4XPages and don´t care about such pain.
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
the job will reopen qractivity when the job is ready.

You should use wait for to wait for the job to finish before you finish the activity.

You should put all the networking into the starter service.

Better solution is to switch to B4XPages and don´t care about such pain.
Thank you @DonManfred ...... It is working as expected....... Thanks for your advice......
 
Upvote 0
Top