The landscape and portrait orientation in android - android

I set the activity landscape orientation compulsory. It locks the screen and then unlock screen in activity.
But now activity screen changed from portrait to landscape.
That is to say after lock the screen it changes to portrait orientation from landscape.
How to keep landscape all the time after I set the activity landscape orientation compulsory? Even it is locked screen.

in AndroidMainfest.xml
<activity
android:name=".path.to.Activity"
android:configChanges="orientation"
android:screenOrientation="landscape" >

Related

Limit orientation support to android app

I want to support my application to support only Portrait and left Landscape mode of orientation.
If My app is in Portrait mode and user changes orientation to landscape-left,
it should change to landscape mode.
But
If My app started in Portrait mode and user changes orientation to landscape-right, it should not change to landscape mode.
similarly
It should change its mode from left-landscape to portrait.
if(screenOrientation == 0){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if(screenOrientation == 1){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
I locked the mode depending on screenOrientation value
but when to unlock rotation. without unlocking it wont change its mode in any rotation.
is anyone have idea about it?
add this line in manifest android:screenOrientation="sensorLandscape"
<activity
android:name=".MainActivity"
android:screenOrientation="sensor" >
</activity>

Prevent orientation sensor using portrait as default

I'm using orientation="sensor" in my Activity. If I start my app in portrait everything works, if I latter change my orientation everything works too (being in portrait or landscape) but if I start my app with my device in landscape, instead of my Activity being launched in landscape (like when it does if orientation="landscape") it first starts in portrait and then changes to landscape.
I want to avoid that, I want to have orientation="sensor", but with the Activity launching in portrait if the device is in portrait or in landscape if the device is in landscape.
How can I achieve this?
Thanks.

I want my android application in landscape and portrait mode only?

I am developing one camera application.I want my application should be in landscape and portrait only.If mobile changes to reverse landscape, application should remain in portrait or landscape mode.And one thing is if device rotated to landscape application should change to landscape, and device changes to portrait, application changes to portrait.
If you want Potrait Mode then:
<activity android:name=".ActivityName" android:screenOrientation="portrait" />
If you want Landscape Mode then:
<activity android:name=".ActivityName" android:screenOrientation="landscape" />
You can use android:screenOrientation= locked on android manifest.
See: http://developer.android.com/guide/topics/manifest/activity-element.html for more info

Tablet devices loading wrong orientation

My app only uses one page which is the main activity and in the manifest it is set not to allow rotation hence the orientation stays the same wether or not you rotate the device. however on tablets when a user is in landscape orientation and runs the app. the app loads the default orientation (Portrait) but in a landscape view instead and im seeing only half the screen.
help.
This is part of my activity in manifest i use nosensor to disable rotation.
<activity
android:name="com.paul.xicon.MainActivity"
android:windowSoftInputMode="adjustPan"
android:label="#string/app_name"
android:screenOrientation="nosensor">
I'm not sure how are you disabling the screen rotation. But this should work just fine in your activity tag of manifest.
android:screenOrientation="landscape" (disables the screen-rotation & restricts to landscape mode)
or,
android:screenOrientation="portrait" (disables the screen-rotation & restricts to portrait mode)

Locked landscape orientation on tablet + activity started when device in portrait = visible rotation on screen

I have an activity with locked orientation (setRequestedOrientation in OnCreate). It works fine on the phone and almost fine on the tablet.
The problem I have is with honeycomb tablets (motorola xoom and samsung), when activity is started when the user holds the device in portait mode, the activity is initially displayed in portait and then after a fraction of a second it rotates to landscape. Is there any way to stop it from happening?
Try to preset it in AndroidManifest.xml:
<activity android:name=".MyActivity"
...
android:screenOrientation="landscape"
/>

Categories

Resources