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.
Related
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...
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"
Hi i am developing android application in tablet version. Here i am facing problem with orientation so i want to make my application in portrait mode only. For that i Used attribute like below snippet for each and every activity in my application.
android:configChanges="keyboard|orientation|keyboardHidden"
android:screenOrientation="portrait"
Application is running perfectly while testing in portrait mode. But it is not good while testing application with tablet physical position with landscape. It is first going to landscape then immediately going to portrait.
I used programmatically making the activity in portrait but no effect. Please provide me any help.
Here is my programmatic orientation fix
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I tested in Motorolo device
Please suggest me to avoid my application going to landscape.
Try this...
<activity
android:label="#string/app_name"
android:name="abc.xyz.dd.MainScreen"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
By adding this in manifest file it will prevent from changing to landscape mode.
Finally i find the reason why orientation changes are occurring in android tablet. In ICS (version 4.0+) the tablet have the option like "Don't keep activities" in settings>> Developer tools>>
If the user checked that option the paused activity will killed and created when it is call again. what i mean the activity won't go for onPause() state it will go for onDestroy() and it will created again when press on back key. So the orientation behavior is different.
I did not get the idea how to handle it from our android code
I don't know if any of you have seen this before:
I have an application which has the Portrait orientation locked for every activity. However, in the HTC Pro Touch phone (and maybe this happens on other phones with physical keyboards) the application rotates to landscape mode for a few seconds and then returns to portait mode, that happens while navigating on the app. Of course this shouldn't happen but I'm not sure why it does that.
I am locking the portrait mode by calling setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) in the create method of my super class.
While I was writting this I realized that the locking instruction is called after the super.create(..), could that make a difference? (Testing takes some time if not I would know right now). If not what else could I do to avoid this auto-rotation?
Thanks in advance, I hope someone knows.
You should set the attribute in your manifest.
<activity android:name="bla.blah.bla" android:screenOrientation="landscape" />
Unless you want to change the orientation later. But that is probably the best way to do it.
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()