control orientation by sensor on Samsung devices - android

I painfully found out today that
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
Does not work properly on the latest Samsung devices.
I want to be able to set screen orientation by the state of the sensor, meaning that even if the device has portrait only set (on device level), if the user rotates the device to landscape my app should change configuration - Reload activity with the proper layout.
SCREEN_ORIENTATION_FULL_SENSOR works fine on any other device, and on old Samsung devices. New Samsung devices do all sort of crazy layout behaviour with that setting.

Related

Delphi Android get device orientation

I want to detect the device orientation in an app that is fixed to portrait mode. If I ask the IFMXScreenService, I get soPortrait no matter how the device is oriented.
This is logical, as the screen orientation is constantly soPortrait. But is there a different service that gives me the information I am after?

System UI crashes when using setRequestedOrientation when Screen orientation is locked

I am trying to force the App into Landscape by using
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
in onResume in a Fragment and set it again to
SCREEN_ORIENTATION_UNSPECIFIED
in onPause so it is only in landscape for this fragment.
This works fine when screen orientation is not locked. But as soon as i lock the screen orientation in android the whole device crashes.
I have testet it with differenet devices and found that it works fine even if orientation is locked on a Nexus 6.
But on my Galaxy S8 it completly crashed.
Also on xiaomi mi mix it the App crashed but the device didn't.
Does anyone know a way around this?
This is what my phone looks like after a few seconds.

Some part of touch screen not working

I am working in an android project targeted for Samsung Galaxy Tab E in Landscape.
The android application starts on boot(as per requirement), after booting, Android by default loads in portrait and switches to Landscape quickly.
The app is already started(Though screen is locked), but the working area in app would be only the width equal to the width in portrait.
This issue appears when screen is locked and orientation of tablet is set to Landscape.
With reference of attached picture in link https://i.stack.imgur.com/4K5Ul.png.
P : is screen when in portrait.
L : is screen when in Landscape.
A : is working portion of L (Whose width is equal with width in portrait mode)
B : is NON-working portion of landscape.
This issue is resolved, and I have explained my case and solution which might be useful for other developers with similar issue.
The issue was not with android application itself. The issue was because android starts my application before boot completion. In my project, android app would run in accessory mode, controlled from another device.
Once the external device gets tablet during restart/power on, my android application starts to run before boot completion, I made another application (app of external device) which sends request to accessory device to sleep for a while when new device is found, so that tablet has enough time to boot and can start app.
Thank you!

Getting the natural orientation of a device in CN1

Is there a method to check the natural orientation of a device's screen in Codename One? Meaning, the default orientation regardless of the device's current rotation or current orientation. (e.g. the result should be on a galaxy tab: landscape, on a galaxy phone: portrait)
Note: Comparing getDisplayWidth/getDisplayHeight is not expedient!
I don't think there is a native API for getting the natural device orientation in any OS. Regardless, iOS only allows you to lock device orientation properly with a build hint so that wouldn't be very useful.

Android App doesn't rotate on normal (non-large) devices

I'm writing a chat app in which I have two different layouts for normal and large devices, similar to the Telegram app. I have an MainActivity that on non-large devices has only a fragment containing the list of chats in it's layout.xml. On large devices the layout.xml also includes a fragment, where you can write in the chat.
My problem is, that on large devices (e.g. Nexus 9 Virtual Device) the app rotates fine when I rotate the device, the activities are reloaded etc. But on non-large devices the app won't rotate after it is started. I have tried this on Nexus 5X API22 and Nexus 5 API23 Virtual Devices and on a OnePlus X and a Samsung Galaxy S7 Edge, all with auto-rotate activated. There is nothing in the AndroidManifest or anywhere else in my code, that has any influence on configChanges. I let Android handle them and don't handle them myself.
I can get the app to rotate on non-large devices when I open the app, got to overview or start another app, rotate to landscape and then go back to my app through overview. After doing this, it reacts normally to rotation. This means I can then rotate it around and the layout/activity is reloaded accordingly by Android.
I couldn't find anything on this anywhere, neither on SO, nor through googling. Please help me, if you have any ideas, where this problem could stem from.

Categories

Resources