Android Question [B4X] B4XPages - Locked orientation limitation

Sandman

Expert
Licensed User
Longtime User
I'm still trying to wrap my head around the new and exciting feature B4XPages and I understand it's still not entirely finalized. However, I saw this limitation:
One notable limitation is that in B4A, the activity that holds all the pages should be locked to a single orientation

I was wondering if this is a limitation that might disappear once B4XPages evolves, perhaps even in the near future? Or is this a limitation that we should never expect to get rid of?

(Reason for asking: I'm about to start a major rewrite of my app in the next couple of weeks. Currently the app it's locked to portrait mode, and to better suit the new features in the app I wanted to also support turning the device to landscape. I would be perfectly fine with launching next version of my app using B4XPages with locked orientation, if I could at least assume that the limitation would be removed at some point during 2020. On the other hand, if it's a limitation that always will be there, I suspect that B4XPages won't be possible for me to use and I'd have to do things old-school instead. That would obviously be acceptable, I'm just trying to avoid making a bad decision on whether to use B4XPages or not.)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Technically we can add a setting in the manifest editor that will prevent the Activity from being destroyed when the orientation changes.
The problem is that many things in B4A are built with the assumption that the activity is recreated in such case, as is recommended by Google.
This is different than in B4J and B4i.

If there is a specific activity that should support both orientations then you can implement it in a second activity together with B4XPages. If the complete app must support both orientations then for now you shouldn't use B4XPages.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
If there is a specific activity that should support both orientations
In my armchair planning of my new app I saw myself using just a single activity for the whole app, and then load layouts into it, depending on what the user does. (Perhaps like a stupid version of B4XPages, I suspect.)

many things in B4A are built with the assumption that the activity is recreated in such case [when rotation is changed]
What are we talking about here? Do you mean internal things in your framework, that we never see or directly touch? Or do you mean libraries that make assumptions about this? Or is it more that some events are never called? I'm just trying to figure out if this limitation is something I could overcome by adding the setting to the manifest and then code a bit differently - or if it's simply not possible for me to bridge the assumption that the app is recreated.

From my naïve view I can't figure out what the problem would be with protecting the activity in the manifest... Actually, it even sounds like a perfect solution, so I'm probably missing a lot here.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
The bottom line is that you will need to recreate the layout again as it will not adjust automatically, like in B4J and B4i.
Since many of my apps (all in house) are like showing reports on the mobile, so I need both portrait and landscape modes to show the reports properly, say image, html, pdf etc.

I am ready to create two pages for portrait and landscape, but it will help me if you give an example as a guide.

Regards,

Anand
 
Upvote 0

dcoun

Member
Licensed User
Longtime User
Please forgive me if the following is stupid.... I am just looking in this functionality
If two events exist to save state and load state in each B4Xpage could this solve this problem?
Probably an other one for initiating variables?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If two events exist to save state and load state in each B4Xpage could this solve this problem?
Not really. Developing with B4XPages is very simple because the pages are never paused or destroyed. Once you let the parent activity be destroyed, all other things will become as complicated as with activities.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Is there a possibility of using

android:configChanges="orientation|screenSize|keyboardHidden"

in the manifest which I understand does not destroy the Activity but rotates the screen and raises an onConfigurationChanged event so we could handle layout changes programmatically?

EDIT: I assume this is what you referred to in post #2 above which I have just read.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The problem is that many things in B4A are built with the assumption that the activity is recreated in such case, as is recommended by Google.
Can you name some for me to look for. I've got this working including broadcasting the new rotation to all the pages.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check B4J / B4i resize event video tutorial: https://www.b4x.com/etp.html
There is no similar feature in B4A. The assumption is that the layout container is never resized.

The meaning is that the layout will need to be recreated when the orientation changes. Whether it is simple or not depends on the app complexity.
With the orientation locked in B4A, the developer doesn't need to deal with such issues at all. No need to worry about the UI state at all.

It is possible that I will add such feature to B4XPages in the future.
 
Upvote 0
Top