I need to study a bit (maybe even the source of B4XPages.b4xlib) but I have a trick in mind that might work ...
WARNING: tested very little.
Public Sub to be added to a code module. It should allow you to set (CHANGE) the page to be shown when pressing the "back button".
[CODE lang="b4x" title="In a code module"]
'PageID must exist, of course.
Public Sub SetPrevPageID(PageID As String)
' Just to shorten the source code.
Dim lstPageIDs As List = B4XPages.GetManager.mStackOfPageIds.AsList
Dim PageIDIndex As Int = lstPageIDs.IndexOf(PageID)
If PageIDIndex >= 0 Then
lstPageIDs.RemoveAt(PageIDIndex)
End If
Dim TopPageID As String = B4XPages.GetManager.GetTopPage.Id
Dim TopPageIndex As Int = lstPageIDs.IndexOf(TopPageID)
If TopPageIndex > 0 Then
lstPageIDs.InsertAt(TopPageIndex - 1, PageID)
Else
lstPageIDs.Add(PageID)
End If
' Log("new stack:")
' For Each ID As String In lstPageIDs
' Log(ID)
' Next
End Sub
[/CODE]
[CODE lang="b4x" title="Usage"]
B4XPages.ShowPage("PageOne")
modProjUtils.SetPrevPageID("mainpage")
[/CODE]