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
Related
I have a android 6.0.1 tablet. My activity is here using following orientation settings:
<activity
android:name=".MainActivity"
android:screenOrientation="sensorLandscape"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize|stateHidden"
android:configChanges="keyboardHidden|orientation|screenSize|uiMode">
When i turn tablet into 180 degree application activity rotate but problem is that when i turn on and off screen using power button on tablet while tablet is in 180 degree, application took few second to rotate. This was not happing in older android version. Is there any android activity setting which i can use to keep remember last screen orientation and keep it same either tablet screen turn off and on ?
Simply use this in onCreate of your activity to disable rotation of activity when screen turn on and off:
((KeyguardManager)getSystemService("keyguard")).newKeyguardLock("keyguard").disableKeyguard();
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>
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)
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" >
I have made a program implementing Camera on surface view.
In landscape mode, the preview is correct, but in portrait mode the preview is tilted 180 degrees, it is not coming upright.
If you are okay with your app always being in landscape mode, then you should add this line to your manifest and it will get rid of your problem:
<activity android:name=".YourActivity"
android:label="#string/app_name"
android:screenOrientation="landscape">
However, if you do want to want a portrait mode application then, you can add this to your manifest:
<activity android:name=".YourActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
as long as you add the mCamera.setDisplayOrientation(90); line to your activity (provided you check for android version greater than or equal to Froyo.