ScreenOrientationChanged: any news about the event handler?

Hello community,

with a delay I want to update a graph (build with Canvas) when a screen changes its orientation. For that reason, I first have tested a delay as follows: when I click on a button I start a timer (Clock1 TimerEnabled set to true) and show a label in a green colour. When the timer expires, the timer of the clock is disabled (see clock1.timer) and the colour is set back to red. This works as expected and changes the colour for the expected time by pressing the button.
The same behaviour I want to get changing the orientation of the screen. Therefore, I used the block “when Screen1.ScreenOrientationChanged” with the same blocks than with the button. But, noting happens when I change the orientation of the screen. This topic has been already discussed here: When Screen.ScreenOrientationChanged Doesn't Do Anything
Have their any changes been done until now? Or is there another possibility to update a graph when the screen orientation changes (without having a timer running all the time and updating the screen i.e. every half of a second!).
I look forward to your answers

Marcus

Figure 1: Program
ScreenOrientation

Export your .aia file and upload it here.
export_and_upload_aia

Attached the .aia file.

ScreenOrientation.aia (2.3 KB)

Insert a label and set its width to fill parent. Then add a second clock and set a variable to store label width(a.k.a screen width). Finally clock2.timer checks if the width is equals to latest one, then stores it, if it is not, performs the action which ScreenOrientationChanged did.

No need to label.

1 Like

Many thanks for the suggestions.
Generally speaking, I exactly wanted to avoid a second clock. But, maybe I am wrong: isn't it too power consuming to have a clock running and checking things, i.e. every 0.2 seconds?
Taking my original task into account: updating a diagram with a clock every half of a second, I would expect to waste battery power. But, checking every 0.2 seconds if the orientation of the phone has changed and update the diagram only after a change of the orientation, would consume less power. The lowest battery consumption I would expect updating the diagram only on the event of changing the screen orientation. Is this correct?

I will test your suggestion later also on my original task.
I look forward to your feedback.

Marcus

ScreenOrientationChanged fires when you set the orientation with blocks. And instead of refreshing every 0.2 second, you set clock to 2 second.

1 Like

The mentioned refreshing time of 0.2 seconds was an example; so you are right, this differs from what you can find in the code.
But I cannot find a fireing of the ScreenOrientationChanges block. I.e. when I want so show the screen hight in this block (see my attached figure), the value is not displayed. Therefore, I think the vaiables of the screen orienation are set, but the block ScreenOrientationChanged has no effect.

ScreenOrientationChanged

Which version of the iOS companion are you using? The ScreenOrientationChanged event should be fixed in the 2.63 version is currently on TestFlight for beta testing.

I use version 2.60 (build 8).
I have tried to update it (and reinstalled it), but I cannot find the new version in the app store. How can I update the iOS companion?

Please see my post about the beta version here:

1 Like

Many thanks for the information.
It seems to work with the new version! But, I will test it extensively tomorrow.

Now I have tested the changing of the screen orientation with the version 2.63 and it works! Just one thing: changing the screen from portrait to landscape works and gives different values for the screen height. That's correct. But, also changing the screen orientation from upright to horizontal fires the block. I think, it is good to know, but was unexpected to me.

:question: Interesting ... :thinking:

It would be for me too.

1 Like

Just for information and further testing (if anybody is interested): please find attached two versions of the complete program, which I am curently working on:

  • The first version contains two clocks, as suggested by Nyctophilia in #5 and
  • the second with the block ScreenOrientationChanged, which will work in build 2.63.

(I know there is still a mistake in the programming, but I hope to find this later.)

GrafikTHG_2ndClock.aia (17.5 KB)
GrafikTHG_screenOrientationChanged.aia (16.0 KB)

So I took a look at this. In Android, the onOrientationChange callback provided by the Android SDK only reports for rotations around the axis that passes through the screen. However, the notifications provided by iOS also includes support for when the device is laid flat on a surface.

Personally, I have a preference towards keeping the iOS behavior as is, but we will need to think about what the best approach is.

1 Like