I have a landscape only application. At times when I start a new activity (form), it kicks back to the main activity with UserClosed = false.
I don't know what is causing this or how to debug it. I am not hitting the back button or the home button. If I hit the button (tab) to go back into the activity, everything works. I display a ToastMessageShow when this happens and UserClosed = false.
Any ideas what to look for or how to debug it?
What is in the Activity_Create that you are attempting to start? It's it possible that nothing is being loaded and therefore the focus is returning to the calling Activity?
What is in the Activity_Create that you are attempting to start? It's it possible that nothing is being loaded and therefore the focus is returning to the calling Activity?
I am doing a LoadLayout of a Mapfragment. It also initializes GPS. This is a Golf app. I have GPS running in the main activity and again in the map activity.
Everything seems to load fine. I see the golf hole and pin marker. Then after 3-5 seconds, it exits to the main activity without touching anything. When I go back to the map after being kicked out, it stays. This does NOT happen all the time which makes it more confusing.
I think this may be the case, but I am a little confused. I had to restart GPS in the map activity because it was not updating when I went from the main to the map activity. So, I thought the main was dormant while the map activity was running. Is HTTP a service running in the background until complete?
I can change my program to work around this.
Any other possible triggers off the top of your head?
OK, I put the GPS code into a service and it appears to work well.
One question: In the (2) UI's that need the GPS data, I created timers to replace the GPS_LocationChanged subs. The timers look at variables in the service Process_Globals. Is this an ok approach?
Service variables
B4X:
Sub GPS_LocationChanged (inpLoc As Location)
gps.cur_location = inpLoc
gps.last_update = DateTime.now
gps.location_changed = True
End Sub
The other way you could do it is to call a Sub from the Service. This way you would only be running the routine when the LocationChange event was triggered.
To do this you would need to know which Activity is running either by storing and updating a Global variable or by asking the system... https://www.b4x.com/android/forum/threads/get-the-current-activity-from-a-code-module.68666/
I think that maybe your solution is the simplest, which is normally my preferred choice. Keep it simple so it's easier to debug.
The other way you could do it is to call a Sub from the Service. This way you would only be running the routine when the LocationChange event was triggered.
To do this you would need to know which Activity is running either by storing and updating a Global variable or by asking the system... https://www.b4x.com/android/forum/threads/get-the-current-activity-from-a-code-module.68666/
I think that maybe your solution is the simplest, which is normally my preferred choice. Keep it simple so it's easier to debug.