Lock Orientation does not always work
I have an iPad (6th Generation), model number MR7G2LL/A. It is running iOS 15.6.1
My app includes the following code:
` public void init(Object context, int product) { _product = product;
MLog.debug(Prefs.getMsg("rw.msg.appname") + " " + Prefs.getMsg("xw.msg.appver"));
Display display = Display.getInstance();
if (display.canForceOrientation() == true) {
MLog.debug("orientation lock supported");
int orientation = Prefs.get("pf.or", 0);
if (orientation == 1) {
// Lock in portrait mode
MLog.debug("Locked in PORTRAIT mode");
display.lockOrientation(true);
}
else if (orientation == 2) {
// Lock in landscape mode
MLog.debug("Locked in LANDSCAPE mode");
display.lockOrientation(false);
}
}
else {
MLog.debug("orientation lock NOT supported");
}
MLog.sendLog();
// Database object is Externalizable
Util.register("MediaObject", MediaObject.class);
`
The output from my iPad is:
`[EDT] 0:0:0,1 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
[EDT] 0:0:0,7 - AWMain - init [EDT] 0:0:0,36 - RW - Music 4.30 [EDT] 0:0:0,38 - orientation lock supported [EDT] 0:0:0,40 - Locked in PORTRAIT mode ` Yet when I rotate my device my screen rotates. This is the only device I have the problem with. All my other devices, iOS and Android work as expected.
Do other devices have the same OS version?
Is this a hardware issue or an OS update issue?
Can you tell if display.canForceOrientation() returns true in that device?
I also have an iPod Touch (7th generation), model MVHW2LL/A, it is also running iOS 15.6.1. It works as expected. My app has a preference setting where the user can set the orientation, use the device setting or lock it in Portrait or Landscape mode. When using the device setting option my screen switches orientation as I rotate the dice. When locked in Portrait or Landscape modes it does not change.
The trace output for this device is:
`[EDT] 0:0:0,4 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
[EDT] 0:0:0,10 - AWMain - init [EDT] 0:0:0,54 - RW - Music 4.30 [EDT] 0:0:0,56 - orientation lock supported [EDT] 0:0:0,57 - Locked in PORTRAIT mode`
So it appears to be a hardware issue with the iPad, not related to the iOS release.