I have a problem with my app, it goes into a loop with Activity_Resume
This is the log:
This is the code:
Kiosk_Service:
The Activity_Resume sub is executed in loop, and I can't use the app. What's the problem?
This is the log:
B4X:
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Service (kiosk_service) Create **
** Service (kiosk_service) Start **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Service (kiosk_service) Start **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Service (kiosk_service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
........continues likewise
This is the code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If Global.Database.IsInitialized = False Then
'Initialize db
End If
Activity.LoadLayout("Layout_Main")
If FirstTime Then
Client.Initialize("Client")
ClientAggiornamento.Initialize("ClientAggiornamento")
ToggleDevice.Initialize
End If
DateTime.DateFormat = "yyyyMMdd"
DateTime.TimeFormat = "HH:mm"
End sub
Sub Activity_Resume
GlobalModule.CurrentActivity = "Main"
Tablet.SetScreenOrientation(1)
PhoneWake.KeepAlive(True)
ToggleDevice.TurnAirplaneModeOff
ToggleDevice.TurnBluetoothOn
ToggleDevice.TurnBrightnessOn
ToggleDevice.TurnGPSOn
ToggleDevice.TurnRingerOn
ToggleDevice.TurnStreamVolumeOn
ToggleDevice.TurnWiFiOn
ToggleDevice.TurnDataConnectionOn
ReadOptions 'read from db and sets variables
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If kiosk = True AND CurrentActivity = "Main" Then
StartServiceAt(Kiosk_Service,DateTime.Now,False)
End If
End Sub
Kiosk_Service:
B4X:
Sub Process_Globals
Dim Notification As Notification
Dim KioskTimer As Timer
End Sub
Sub Service_Create
If Notification.IsInitialized = False Then
Notification.Initialize
Notification.Icon = "icon"
Notification.SetInfo("Kiosk_Service","","")
Notification.Sound = False
Notification.Vibrate = False
End If
KioskTimer.Initialize("KioskTimer", 800) '800 ms
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(1, Notification)
KioskTimer.Enabled = True
End Sub
Sub Service_Destroy
KioskTimer.Enabled = False
Service.StopForeground(1)
End Sub
Sub KioskTimer_Tick
StartActivity(GlobalModule.CurrentActivity)
KioskTimer.Enabled = False
End Sub
The Activity_Resume sub is executed in loop, and I can't use the app. What's the problem?