I've done some testing. I used this (somewhat sloppy) test code:
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
Log("Receiver_Receive got a geofence event")
Dim loopcounter As Int = 0
Dim bp As Boolean = B4XPages.IsInitialized
Dim start As Long = DateTime.Now
Do While Not(B4XPages.IsInitialized)
Log("Loopcounter: " & loopcounter)
loopcounter = loopcounter + 1
Sleep(1000)
Loop
Log("Loop done")
Dim total As Long = (DateTime.Now - start) / 1000
If bp Then
ToastMessageShow("B4XPages available from start", False)
Log("B4XPages available from start")
Else
ToastMessageShow("B4XPages available after " & total, False)
Log("B4XPages available after " & total & " sec")
End If
' Standard geofence code here, removed in this code block because it's not relevant
End Sub
After putting the app in the background and making sure it doesn't run, I trigger a geofence event by changing the location. I can see the initial log message confirming that the receiver got called. And then it goes into a never-ending loop. Or, rather, I imagine it's never-ending. When it's counted for ten minutes I've killed the app, because it just doesn't seem very reasonable that B4XPages would randomly be available after longer than that.
As far as I can tell, I can't assume that the rest of the app will automatically be available, not even if I wait for it.
So now the question is how to start B4XPages and the rest of the app. Is that possible to do? Please note that I have no interest in bringing the app to front, I just want to access code in other modules.
Or should we declare enough classes in the receiver to make a duplicate version of the whole app - but a very stripped down version, just enough for the receiver to do its job?
An observation: It's interesting that the receiver isn't killed. It was my understanding that they were meant to be very short-lived and should expect to not live more than 10 seconds. Erel has said that he has seen them live longer, but ten minutes is very much longer, so that's surprising...