There is still too little info for me to fully understand what you want to do.
For example I don't know what you mean by "The orientation is cached in a file."
What I get so far is (assuming that the starting orientation is portrait):
1. You have 3 pages
2. The second page has a button that when pressed closes all pages and restarts the Activity
3. On restart the orientation should be landscape, but the app should continue where you left off
Am I right?
It is possible to put the desired orientation in an external file and read it upon activity start.
Then set it before running pm.Initialize
Below is how I usually modify the Android B4XPages template for Main
Replace line #28 with a poll of the external file holding the desired orientation.
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified 'this will cause a warning in logs - but ignore it - it is needed
#CanInstallToExternalStorage: False
#End Region
Sub Activity_Create(FirstTime As Boolean)
Dim ph As Phone 'include Phone library
'the next line will set the orientation to how the user was holding the phone when the App started
If Activity.width < Activity.Height Then ph.SetScreenOrientation(7) Else ph.SetScreenOrientation(6)
'now the B4XPages context has a fixed orientation as required
Dim pm As B4XPagesManager
pm.Initialize(Activity)
End Sub
'Template version: B4A-1.01
#Region Delegates