Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Changing FormFactor.Orientations breaks autorotate on android


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Oct 27, 2014 11:20 AM Last Post By: Malcolm Taylor
David Drouin

Posts: 16
Registered: 11/11/11
Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 24, 2014 9:34 AM
setting this anywhere in the code breaks auto rotate on Android, what am I doing wrong?

Application.FormFactor.Orientations := [ TFormOrientation.soPortrait , TFormOrientation.soLandscape ]; (default)

Edited by: David Drouin on Oct 24, 2014 9:47 AM
Chris Dunn

Posts: 160
Registered: 8/22/11
Re: Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 24, 2014 1:05 PM   in response to: David Drouin in response to: David Drouin
are you trying to change orientation at runtime in a unit?
David Drouin

Posts: 16
Registered: 11/11/11
Re: Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 27, 2014 5:05 AM   in response to: Chris Dunn in response to: Chris Dunn
I am trying to force landscape for a specific panel and turn it back to default once done with the panel. Everything seems to work find but when I re-apply the default, the application doesn't seem to trigger portait or landscape when I tilt the phone. It is stuck in portrait.
Malcolm Taylor

Posts: 148
Registered: 7/16/01
Re: Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 27, 2014 7:06 AM   in response to: David Drouin in response to: David Drouin
I am doing the following in XE7 for android and it may help you.

I want my MainForm to stay in landscape but let the user choose between
'normal' and inverted which is not supported in Project Options. But I
also sucessfully tested switching between portrait and landscape using
the same approach.


PROCEDURE TfrmMain.btnInvertClick(Sender: TObject);
BEGIN
  IF (TFormOrientation.Landscape IN
Application.FormFactor.Orientations) THEN
    Application.FormFactor.Orientations :=
[TScreenOrientation.InvertedLandscape]
  ELSE
    Application.FormFactor.Orientations :=
[TScreenOrientation.Landscape];
END;
 
David Drouin

Posts: 16
Registered: 11/11/11
Re: Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 27, 2014 9:45 AM   in response to: Malcolm Taylor in response to: Malcolm Taylor
Do you mind trying this code?.

 
 PROCEDURE TfrmMain.btnInvertClick(Sender: TObject);
 BEGIN
   IF (TFormOrientation.Landscape IN
 Application.FormFactor.Orientations) THEN
     Application.FormFactor.Orientations :=
 [TScreenOrientation.InvertedLandscape]
   ELSE
     Application.FormFactor.Orientations :=
[TScreenOrientation.Landscape,TScreenOrientation.Potrait];
 END;
 
 


i just added portrait on the ELSE. see if android auto rotate if you tilt the phone
Malcolm Taylor

Posts: 148
Registered: 7/16/01
Re: Changing FormFactor.Orientations breaks autorotate on android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 27, 2014 11:20 AM   in response to: David Drouin in response to: David Drouin
David Drouin wrote:

Do you mind trying this code?.

I don't think it will work because if you specify a single orientation
(or both portrait or both landscape ones) it will ignore the sensor.
In my brief tests, I had to set a single orientation to make it change
under software control and that then seems to disable the sensor.

You could try changing your orientation back to portrait by setting a
single value, then restore the default two values to (possibly)
re-enable the sensor. But it may be that once you mess with the
settings you unsubscribe from the sensor.

I Googled and found a Stack Overflow thread showing how to subscribe to
the sensor service. That might allow you to enable/disable to the
sensor but I don't know.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02