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?
Related
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!
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.
I have a project requirement to create a kiosk based application which will always be in the landscape mode,for which I am making use of a tablet running on 4.2.2.One of the modules has the functionality to make phone calls.For making the calls from my app, I invoke the default android dialer app.However,I notice that even if my device is physically in the landscape mode,at times when the default dialer app is called,it first displays its portrait layout and the quickly switches to the landscape one(which is not visually appealing).Now,since I do not have access to modify the source code of the default dialer app,I was wondering if there is a way that I can specify a system level screen orientation as landscape ?
PS: I have root access for my tablet.
Any help would be appreciated.Many thanks !
There's an app for that: Rotation Locker
You can also add the switch ro.sf.hwrotation 90 in your build.prop file
My app has 3 screens, and all of them must be portrait-only in smartphones and both orientation for tablets.
Unitl now I was using the following code in OnCreate:
if (!getResources().getBoolean(R.bool.isTablet)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
However if I hold the smartphone in landscape mode and launch the application it will show in landscape for a few seconds then rotate to portrait.
Many answers here suggest locking orientation via manifest, but that would lock the orientation in tablets, which is not desired.
I would be very grateful for any information that leads me to a solution. Thanks.
You could lock it in the Manifest and then unlock it in code if it's a tablet.
It may not matter for your case, but I've read that the Nexus 7 doesn't report itself as a tablet using the method you do. I'm not sure that's accurate though, never having tried it myself.
I have an android application that I want to always be running in landscape mode.
I have the following code implemented to keep the app in landscape mode all the time:
inside my activity in the Application Manifest
android:screenOrientation="landscape"
This seems to launch and keep the application in landscape view for the whole duration of the application. Perfect!
However, if I have the app running on my HTC Aria (Android 2.1) and the phone locks, if I unlock the phone, I see the application for probably half a second and it's in portrait orientation and then quickly switches back to landscape mode. It is quite frustrating because all of my views are jumbled around and it looks unprofessional as you can imagine. This happens in both the emulator and on my real phone.
Does anyone know how to stop the application from temporarily rotating when the phone is unlocked?
Additions:
I have tried overriding onConfigurationChanged() but with no success.
I have also tried putting setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); into the onResume() but the app still shows as the incorrect orientation for a split second when the phone is unlocked.
Try setting the orientation in the manifest file. it might just work.
After looking at many other apps that are made for landscape orientation only, I can see that their apps don't freeze their orientation after standby either. I have a feeling that this is a limitation of the phone, and that all apps will switch to a portrait orientation when the phone is locked. If all apps have this "problem" then I think it is acceptable not to fix.
Please post if you have found out there is a way to stop the forced portrait orientation.
the app still shows as the incorrect orientation for a split second when the phone is unlocked.
Did you move setContentView(R.layout.main) to the onResume, AFTER where you put your orientation code? I would try setting the orientation, then the setContentView()