I'm building from AOSP source code. I have a specific requirement where I need my phone to start in landscape mode, which includes Boot Logo, Animation (Well these can be done by rotating the animation frames). I would want to restrict the device to display only in landscape mode. I have used rotation lock app but I want to have it as part of the OS so the "Android is starting" boot message also will be displayed in Landscape. Where can I make the required changes in the source code? Your inputs are much appreciated.
You can set the user rotation in Android. But it only take efferts after the Android boot completed.
If you want to rotate the screen of boot logo, and boot animation, you should rotate the display in low level. There are some place to define the rotation in the display driver and bootloader.
I don't know the exact code place. You may ask you vendor whether the display rotation can be configured. I know that MediaTek provided the configuration to rotate the display.
Related
Our team has recently updated a system application (installed in priv-app) from Android 5 to Android 9. This seems to have broken the previously working (and relatively well documented approach) of programmatically flipping the device orientation.
We had been using this approach and it had worked at globablly flipping the device orientation 180 degrees:
Settings.System.putInt( context.getApplicationContext().getContentResolver(), Settings.System.USER_ROTATION, 2)
We check each time to make sure the accelerometer rotation is disabled also. The setting does in fact stick as when interrogate the settings provider and can see the value being updated, the screen is simply not reacting, even after a reboot etc..
I'm trying to understand if Android 9 introduced any further gotchas that can prevent a screen rotation from happening, would be grateful if anyone had any insight on this particular issue?
You can instead use Activity.setRequestedOrientation() if its a particular Activity your want to change. This can be set explicitly to portrait, reverse portrait, landscape, reverse landscape, etc... It will then lock to the orientation you set. You can use the various sensor values if you want it to be flexible for the user.
If you want to know what your current orientation is (including reverse orientations) it can be complicated but I just answered my own question here about how to do it - Android sensor orientation problems with edge-to-edge insets
If you want to change the system rotation
You need to ensure ACCELEROMETER_ROTATION is off and then the value you use needs to come from the surface rotation constants (which are relative to your displays natural orientation) - https://developer.android.com/reference/android/view/Surface#ROTATION_0
Another quick edit - any Activity can override this setting (including a launcher) for themselves. So it may be that whatever you are running is actually what changed to lock or allow certain orientations.
I'm just starting a cardboard project as it's really joyful to experiment VR without any huge hardware, but I have a little problem which sounds really basic : the screen orientation. I just would have my game playable in Landscape Right instead of Left as I'm developing on my Xperia Z.
Usually screen orientation's problems are solved by forcing the orientation through the Player's Settings in the Build Menu. But here, the fact is that when I tick the "Landscape Right" box instead of the left one (which is the default setting of the Cardboard API) it correctly inverts my display but my camera stays at the same orientation as before.
From this results that my gyroscope works in reverse and that the ground is seen on the top, with all the texts reversed as well.
I've already done what Eldir tried here (Google cardboard device orientation) but as it wasn't the same problem I'm having, it wasn't efficient.
Do you have any ideas that if the API allows a quick change for this, or if I have to modify the whole parameters of the gyroscope ?
Thanks !
I am using Metaio SDK 5.3 (for Android) for Instant Tracking.
My aim - I want to capture an image on device A and want use the same image for tracking on device B.
My approach - I have extended InstantTracking tutorial to capture an image and save it to send it across to device B using this method,
metaiosdk.requestCameraImage(path);
And am saving the tracking XML file simultaneously, to send across to device B.
Problem - When I capture an image in PORTRAIT mode, somehow, metaio saves it in landscape mode and so the resulting augmentation is 90 degrees rotated. When I capture an image in landscape mode, the augmentation is perfect.
Instant tracking initiated by "Instant 2D" button when device was in landscape mode. Augmentation content was augmented in landscape mode, alt text
Instant tracking initiated by "Instant 2D" button when device was in portrait mode. But this time, augmentation content was augmented in landscape mode, alt text
Is there a way I can control how the captured image is saved? Or why is metaio saving the portrait image in landscape mode?
Am I missing something here? Any help is much appreciated.
Thanks in advance!
Please see the answer on Metaio Helpdesk:
http://helpdesk.metaio.com/questions/33971/portrait-mode-image-saved-as-landscape-mode-by-requestcameraimage
First of all, I would like to refer to this Issue on the google groups.
My problem is i want the landscape-native app to work in portrait mode. The way of getting the app into portrait mode is no problem at all, but when you display the app in portrait mode, my problem occurs.
When the Barcode Scanner is starting op, its camera view is (pr. default) at a +90 degree angle. When viewing the app in portrait mode the Barcode Scanner is (naturally) still at a +90 degree angle.
In the referred Issue-page there is displayed a hack to get around the problem, but this does not seem to work on most devices. This does also not work on my targeted devices.
I would like to hear if some of you have got a work around, or found the place in the source where you can 'undo' the 90 degree flipping?
A usable answer will be utmost appriciated :D Unfortunately i can't make progress in the project before this is solved. It is demanded to run in portrait mode ;)
In advance ... Thanks :)
I have implemented this in a private build. It is complicated and I can't share the details. The key steps are:
Call Camera.setDisplayOrientation() to counteract the rotation; see the Android javadoc for some discussion on that
Make sure that Camera.Parameters.setPreviewSize() is called correctly; preview sizes are reported in landscape but need to be set in portrait
(And guess what -- the default orientation of phones is considered portrait but tablets is considered landscape! Make sure you've accounted for that too.)
Finally, the preview data is always in landscape mode. You need to rotate it yourself to read it right-side-up, or otherwise account for that.
I know you can set orientation using android:screenOrientation statically and setRequestedOrientation programatically. However the problem is that if I use either of these to set the screen orientation I do not get to choose which landscape or which portrait I want. To wit, flipping the phone 180 degrees does not rotate the view but rather just appears upside down to the user. I cannot use screenOrientation="sensor", because in some cases I would only want the view to be landscape OR portrait and seldom both. This seems insignificant until you consider external hardware.
If I developed an app and set the layout to android:screenOrientation="landscape", the app would only display correctly if the left side of the droid were sitting on a desk. Unforunately the left side is where the usb port is, so the phone would not sit very well on that side if it were plugged in. Unless of course they used a docking station but that is not the kind of help I am looking for. If the right side of the phone is sitting on the desk to allow for the cord, the display appears upside down. I tried posting an image but being a new user I was not able to do so.
What I would like to know is how to programmatically choose which landscape (Surface.ROTATION_90,Surface.ROTATION_270) or portrait (Surface.ROTATION_0,Surface.ROTATION_180) orientation I wish the user to see, but more importantly allow them to do so in the app's settings activity. I have googled for quite awhile and all I can find are sensors that tell you when the orientation/rotation has changed and to what, but none show how to programmatically set either.