FMX + Android + Rotation

  

Trying to determine a "180° flip": all of the above methods are useless when the device is quickly flipped (for example from "Landscape" to "Reverse landscape") 😕
But there is a "native way" — through the OrientationEventListener. Can anyone help make it work?
unit android.view.OrientationEventListener;

interface

uses
AndroidAPI.JNIBridge, Androidapi.JNI.JavaTypes, Androidapi.JNI.GraphicsContentViewText;

type
JOrientationEventListener = interface;

JOrientationEventListenerClass = interface(JObjectClass)
[‘{6C04CBB1-63B1-45E1-9CBE-AE3F41A60064}’]
function _GetORIENTATION_UNKNOWN: Integer; cdecl;
function canDetectOrientation : boolean; cdecl;
function init(context: JContext): JOrientationEventListener; cdecl; overload;
function init(context: JContext; rate: Integer): JOrientationEventListener; cdecl; overload;
procedure disable; cdecl;
procedure enable; cdecl;
procedure onOrientationChanged(Integerparam0: integer); cdecl;
property ORIENTATION_UNKNOWN : Integer read _GetORIENTATION_UNKNOWN;
end;

[JavaSignature(‘android/view/OrientationEventListener’)]
JOrientationEventListener = interface(JObject)
[‘{ED4F435E-E48F-420E-A26E-75BFB8FCCB94}’]
function canDetectOrientation: boolean; cdecl;
procedure disable; cdecl;
procedure enable; cdecl;
procedure onOrientationChanged(Integerparam0: integer); cdecl;
end;

TJOrientationEventListener = class(TJavaGenericImport<JOrientationEventListenerClass, JOrientationEventListener>)
end;

const
TJOrientationEventListenerORIENTATION_UNKNOWN = -1;

implementation

end.

Comments are closed.