setting emulator landscape mode problem - android

I have developed a project which should run only in landscape mode. I set in manifest file like this android:screenOrientation="landscape". This is working fine in emulator but when i am running in nexus one it is still coming in portrait mode.Any idea any one?

Dunno, AndroidMirza. I tried it on two Nexus One phones, one running Gingerbread and one running Eclair, and it works as expected. Here's what I did:
Create Android project
Open AndroidManifest.xml
In <activity> tag, add:
android:screenOrientation="landscape"
In both cases (and AVD with GB), the screen orientation immediately locks to landscape in my Activity. I used [Ctrl] + [Space] to let the IDE auto-complete for me, to make sure there were no typos.
All I can think is, either there is an error in how you are specifying landscape, or something elsewhere in your code or manifest is defeating it.

When I want one of my apps running in landscape mode I add on my onCreate the following line :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Hope that is what you expect.

Related

Portrait app shows as Landscape

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"

How can i stop orientation change in android table?

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

Air Android app crashes when phone changes orientation

... 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.

Android application orientation change behavior

I'm done with developing an android application and in phase of testing it. I've tested it with the simulator and everything is working perfect, but when I deploy it on devices, some of them when you change the screen orientation the application screen starts to flicker.
Any clue where to start the problem investigation from?
When orientation changes from portrait to landscape or vice versa, onCreate gets called again, making the application to start from the beginning. Make sure you are handling it in manifest by declaring android:configChanges="keyboardHidden|orientation" infront of your class name or override onConfigChanged() function.
Please check Both Device version and Developing Application Versions are the same or not, and clear the application after install to the device and then run.

Handling orientation on lockscreen for an android app

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.

Categories

Resources