good evening people.
Simple question
why
mActivity.setRequestedOrientation(force ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
turns 'auto rotate' from device's quick settings icon ON ?
seems like setRequestedOrientation() globally changes system preference regardless activity which called setRequestedOrientation is running or not.
I bet its some additional "feature" or behavior of your Android version modified by manufacturer. check on some other device from different manufacturer or at least different Android version. you can also try to use emulator
I have some old tablet with clean Android version, which have broken gyro/accelerometer, works only for few hours after device reset. so I've disabled auto-rotate and set fixed horizontal orientation on it. still when I run my app with similar code to yours forcing portrait mode then it will show in portrait mode as intended, but when I exit my app then whole interface/previous app runs in horizontal - still no auto-rotate option enabled
Related
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
this is my first post so please correct me if I do any mistake regarding rules :-)
Heres my problem:
I am trying to set a fixed screen rotation for all Apps on an Android device
(not just my App). I searched a lot but found only solutions for single Apps.
I had the following Ideas:
1) Use the API ==> seems not possible
2) Change accelerometer values ==> seems not possible
3) virtually open a hardware keyboard ==> seems not possible
Turning off autorotation keeps all Apps in portrait mode, but I would like all
Apps to be in landscape mode.
Can anybody help me please?
At least for Android 4.2. (Nexus 7) you can hold device in landscape mode and then disable autorotation. Afterwards all apps work in landscape mode.
... or at various settings in the app xml (<appName>-app.xml or application.xml) when holding the phone in Portrait-orientation instead of landscape-orientation.
Depending on various settings our testphone, Samsung Galaxy s3, crashes right at launch when we do debug on the phone in FlashDevelop. Actually we are debugging with a release so we don't get any traces, but all the same we are running the app on the phone.
For instance if we set
<aspectRatio>landscape</aspectRatio>
<autoOrients>true</autoOrients>
and hold the phone in landscape orientation when we start the debug, then the app runs as should be.
However if we with the same settings hold the phone in portrait orientation when starting the debug, then the app crashes on startup.
The exact same happens if we set auto orient to false and/or remove the Aspect Ratio.
It also doesn't matter what we set stage.scaleMode to in my Main class... or at least i've not been able to figure out any combo with aspectRatio/autoOrients/ that works.
I read something at a glance here at Stack Overflow in another thread about something that seemed similar was a bug in earlier Android versions, but that it should be fixed in ICS (which we have on the test devices).
And I may also have seen something at a glance about it being related to the virtual keyboard and to add some code in the xml Manifest at various actions..
Does anyone have a clue for sure please? :-)
edit:
The App is built to only ever be shown in Landscape orientation. It can't work in portrait.
I have also encountered same problem; app crashes everytime orientation changes. What I did was very simple:
FIRST, create two folders for your layout:
layout
layout-land
Then, put your portait layouts in layout and landscape layouts in layout-land.
This will do the trick. Hope you can get idea from my experience.
I am running android 3.2 RC2 eeepc on Virtual Box.
The OS assumes it a tablet and sets the orientation to landscape by delfault.
How can I manually change the orientation between landscape and portrait?
Is there a way to do this through the commandline in the android OS?
Is there a shortcut key like the emulator from AVD Manager?
I tried Numlock off 7 and Ctrl F11. No use. Kindly help
I use the VM to run an app that I am currently building.
My app has many views and most are set to work in both portrait and landscape.
One view is strictly set to portrait. When I launch this, the entire OS turns to portrait.
How to revert to landscape mode?
download apps like "Set Orientation" so u can set it as potrait, lanscape or automatic
Sadly, VBox is really bad at handling screen orientation. There is no shortcut to change screen orientation on the go I'm afraid. However, there are ways to force the screen into one orientation always. This is however probably not what you were looking for.
You could however try going with BuilDroid - which is a type of addon for VBox to try and support Android as best as possible. It makes sure that screens are "managed". I have no experience with BuilDroid myself, but it could have what you're looking for.
Try it out! You can find it here: http://www.buildroid.org/blog/?page_id=121
Alternatively, there's a blog post giving information on how to change the orientation permanently, as I mentioned before, here: http://davematthew.blogspot.com/2011/09/app-development-with-android-x86-on.html
I have no idea if that helps you either though! But I hope one of these answers your question.
EDIT: The problem seems to have been solved by apps such as the one user2835272 referred to. I have not tried the app personally, but trying "Set Orientation" might be a proper solution for the problem now. Even better, if F9 - F12 works now, that is the functionality that should be used. Again, I haven't played around with VM Android for a while, so I cannot confirm this.
Try just using F9 or F11. It worked for me.
I encountered this problem when trying to run QQ on Android 4.4 running in VirtualBox. F9-F12 were ineffective as soon as QQ started. The app "Ultimate Rotation Control" does the trick but does not resize the QQ window. So part of it gets to lie out of the virtual screen. Finally, I ended up redefining the screen size of the virtual Android to 360x640 (portrait) as described here. It seems that QQ detects which side of the screen is longer and rotates according to this. So if you start with a portrait aspect ratio it will not rotate sideways. I do not about other apps, but guess they operate the same way.
If you are trying to set the display to a portrait resolution. There is one way to set the resolution manually in VBox
I set it to 600x800 successfully in Android x86 4.4.
So basically do the following:
VBoxManage setextradata "Android" "CustomVideoMode1" "360x640x16"
Start Android in VBox in Debug mode
At the Linux prompt, enter the following commands:
mkdir /boot
mount /dev/sda1 /boot
vi /boot/grub/menu.lst
Find the line with tile like "Android-x86 4.4", add "UVESA_MODE=360x640" (replace 360x640 with your resolution) at the end of the line
Save the file.
Clean up and then restart the VM.
umount /boot
rmdir /boot
reboot –f
For those who want to change the screen orientation on Windows.
To run VB on the full-screen mode on a vertical screen, select different sizes and scales from view>>virtual screen x>>resize to ../scale to xx%. After trying different combinations you will find the right settings for you.
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()