My app has 11 tabs on it. I set an image on the tab as the user progresses through the app. The problem I am seeing is when the tablet is shutdown, it doesn't appear to reset the app. It continues where it left off. The tabs still have their images on them and textboxes are filled in. I'd like it to start the app fresh when turned the tablet is restarted, wiping any previous entries.
This is my Activity_Pause procedure.
B4X:
Sub Activity_Pause (Finishing As Boolean)
Try
If kiosk Then StartServiceAt(KioskService, DateTime.Now + 1 * DateTime.TicksPerSecond, False)
If Finishing Then
StateManager.ResetState("Main")
Else
StateManager.SaveState(Activity, "Main")
End If
StateManager.SaveSettings
Catch
Ex = LastException
cErrorLog.InsertLog(3,"CustomerTablet.Main.Activity_Pause",Ex.Message)
If DebugMode Then
Log(Ex.StackTraceElement(0))
End If
End Try
End Sub
I don't know how users leave your application but something like this should work
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK OR KeyCode = KeyCodes.KEYCODE_HOME Then
If Msgbox2("are you sure you want to exit the application", "", "Yes", "Cancel", "", Null) = DialogResponse.POSITIVE Then
StateManager.DeleteStateAndSettings
Activity.Finish
Else
Return True
End If
End If
End Sub
Just tried it but didn't work.
What I am doing is working my way through a few tabs and then powering off the tablet. When I power it back up, and the app starts, it continues where it left off. The data is still there.