Android Question B4A changing Orientation

CR95

Active Member
Licensed User
I tried Erel's sample (#13) for moving from portrait to landscape with 2 activities:
It works fine... until I move the code in my B4XPage application.
Creating the second activity and moving current video from portrait to landscape are going well until KeyCode Back is pressed in the second (landscape) activity.
With debugging, issue is coming on line "Activity Finish" or "Return True"
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
    Log("Clic sur Full Screen")
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        Dim Page2 As Video
        Page2 = B4XPages.GetPage("Video") ' Accès aux constantes
        Page2.PlayerVideo.Pause
        CallSubDelayed("Video", "ReturnFullVideo")
        Activity.Finish
    End If
    Return True
End Sub
I attached a picture with the code and the error message
Please could you help
 

Attachments

  • PortraitToLandsscape.jpg
    PortraitToLandsscape.jpg
    184.9 KB · Views: 121

CR95

Active Member
Licensed User
@agraham,
Thanks for your explanation
I did not understood that B4XPages supports only ONE single activity.
Yes, my application is using several (vertical) B4XPages. Unfortunately (I made the trial), it is not possible to get simultaneously lanscape and portrait with B4XPages (my video stays vertical). That's why I tried Erel's sample with 2 activities.
At the end, does that mean that it is not possible to get portrait and video in the same B4XPages app ?
Thanks,
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
At the end, does that mean that it is not possible to get portrait and video in the same B4XPages app ?
Yes, it's a deliberate design choice by Erel to hide the activity lifecycle and avoid it's save and restore complications. You can hack it but it's messy and a bit pointless. You can still launch a separate activity and have that rotate but it won't be part of B4XPages and will need a manifest entry for that second activity to allow it to rotate.
B4X:
SetActivityAttribute (ActivityName, android:screenOrientation, "unspecified")
Replace 'ActivityName' with the name of that activity module and start it with StartActivity(ActivityName). This Activity will be independent of the B4XPages activity and will have its own lifecycle events. You will be able, as always, to access the Process_Globals of Main and Starter.

PS. This is what I do with my BasicIDe where the Main Activity is limited to portrait orientation, just like B4xPages Main, but the launched second activity running the script is free to rotate.
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
@oparra

Thanks for that link. I haven't had any need for Video, but the example is compact and illustrates several interesting techniques, including the above.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I used it to develop a personal app, for my phone and my car, where I see a list of movie and news channels.
example:
1643990314385.png
1643990353823.png
 
Upvote 0

CR95

Active Member
Licensed User
@agraham
Thanks. I understand your explanations end EREL's choice as well. I am not enough expert for hacking the system

@oparra
My understanding (and the sample you provided which is different from the one I started) is that it is possible to have landscape and portrait orientations when using B4XPages !!!!
I need to spend time to understand your code and the "PutLabelInVideoTopRightCorner" feature
The way to add the "full screen icon" inside the display is also very interesting
Thanks to all
 
Upvote 0
Top