I have build android application and in manifest I have android:screenOrientation="sensorLandscape" also I use android:configChanges="locale|keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" I mention it just because maybe it can be related to my issue.
When I turn my phone to portrait and press home button to go to home screen and go back to my app in portrait it sometimes get displayed in portrait for a second and the it switches to landscape but this happens just very rarely.
Also I get random layout changes like you see in pictures. This all happens just like this I turn phone to portrait while my app is supposed to be landscape only based on my manifest definition.
My guess is that somehow android system is switching my app to portrait before recognizing it as landscape but I don't know how to fix it. I would like to to stay sensorlandscape too so I get it rotated for both landscape orientations. Maybe this is phone specific behaviour and some others don't do it (thats even worse then), hard to say app is not released yet...
On first picture you can see correct layout and others are how it gets randomly corrupted by having phone portrait and going to home and back to running app again...
Related
I'm developing an Android Application which is locked to portrait mode for phones. In one part of the application, the user can look at some nice Graphs. In this part (only), it would be nice to allow the user to change to landscape mode - if he wants to.
I know this would be quite simple if the Graphs were contained in their own activity, but unfortunately, they are not. They are shown by Fragments which in turn are shown in a somewhat complex Tab Layout.
In other words; I want to have to whole app locked to portrait mode except when the user is in a specific Fragment. Then I want to allow him to allow him to change to landscape mode (Not neccessarily by rotating the device, other solutions are welcome too). When the user navigates away from that part of the app from Landscape mode, the portrait mode should be restored.
Is there any way this can be achieved?
you can do it dynamically this way :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
I am an Android developer and have recently made an app for a client. The screen orientation should only be available in portrait, so I have added the option android:screenOrientation="userPortrait" to each and every activity in my manifest.
Despite this, my client keeps telling me that the app displays in landscape on her Samsung Tablet. I don't know why this may be, according with http://developer.android.com/guide/topics/manifest/activity-element.html the orientation should never be landscape. In all of my tests it is displaying correctly (portrait mode), but I don't have access to her device and don't know what is going on.
Any help would be appreciated. Thanks!
You should write this :
android:screenOrientation="portrait"
... 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.
Testing my application on my Galaxy S2 I have a problem whenever the screen is turned off and back on. My application is locked into landscape by the manifest. The lock screen forces the application into some weird orientation where it is rendering portrait but displaying it was landscape (as in the right 2/5 of my screen is black and the portrait rendering goes off the bottom). The application is also not responsive in this state. If I quickly hit home (or back) and recall the application it works perfect.
As well, if I use a different lock screen (tried with PowerAmp) it works flawlessly.
So can anyone help me understand why this is screwing up and how to fix the orientation whenever this happens?
I can avoid this by avoiding the lock screen through a flag (window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)) but I don't have any other reason to avoid a lock screen and would like to know what is happening.
This sound like a problem that is unique to the S2. Have you tried your app on the emulator or any other devices. It may just be that the S2 implements some part of android incorrectly.
To handle the orientation problem in your application try to use this for your activity like this
<activity android:configchanges="orientation|keyboardHidden" />
in your Android Manfiest file.
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()