screenOrientation portrait not always working - android

I'm making activity which should always remain in one orientation on all devices, preferably portrait.
here is my activity
<activity
android:name="com.example.app.Settings"
android:label="#string/settings_activity_title"
android:autoRemoveFromRecents="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
It works on phone devices but when I tested on virtual tablet it didn't.
I test on Nexus 9 in Android Studio and made my own device with dimensions 2500x2500, screen size 9in.
In such cases, screen will still rotate.
I have also tried setting orientation programmatically inside onCreate method but it didn't help.
I tried to find any information regarding this problem but couldn't.
My question is if this is related to android studio emulator, or this can happen on physical device

Related

Tablets: android:configChanges="orientation|screenSize" and screen disabling issue

I have application with screen rotation.
rotating mechanism i handle with configChanges:
<activity
android:name=".ui.activity.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Problem:
When user turn off screen, rotate device on 90 degrees and unblock it screen start with "old" orientation of my app, it look ugly.
here scheme:
after block and rotate i get this
blink and app come to normal
try it on Nexus 5(android v5) and Nesus 10(android v4.4), at phones all works fine
Adding android:configChanges="orientation|screenSize" tells the system that you are going to handle these config changes yourself, and for the system to not do anything about it.
By removing them, your activity will be recreated with the correct layouts when you rotate.
If you're using configChanges to avoid the activity being recreated, I feel bad for you son.

Changing Orientation in Bluestacks to test Orientation Change of my App

Android Emulator 4.4 apparently has a bug which keeps it from changing rotation appropriately. Having heard that Bluestacks is faster anyway, I wanted to give it a shot, but I can't find a way to change my orientation while in my app. My app launches in the full tablet-sized screen of Bluestacks and that's that. The system tray options don't help. I want Bluestacks to look and behave like a standard android phone, with the ability to rotate.
It looks like other versions of Bluestacks have had a rotation button (and other buttons)? I find references to this, but it's not in the latest version I downloaded. Any ideas?
Using the icon on the system tray, setting it to enabled worked for me.
You also have to check if you are forcing the portrait orientation on your manifest. I had to put the tag on every Activity tag, not on the application tag. Like this:
<activity android:name="com.example.LoginActivity"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.MainActivity"
android:screenOrientation="portrait">
</activity>

how to force an Android app into landscape only or portrait only? [duplicate]

This question already has answers here:
Lock screen orientation (Android) [duplicate]
(3 answers)
Closed 8 years ago.
how to force an app into landscape only or portrait only? I want to app locked into the orientation of user choices.
Thanks a lot for sharing!!
<activity android:name="Intro"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.gmaninc.package.INTRO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
one of the following in each activity in the manifest
android:screenOrientation="portrait"
android:screenOrientation="landscape"
Follow below steps to achieve what you wanted to do..
Open Android Manifest file.
Set Orientation to Portrait or Landscape
that's it..

How does one catch the onsize event (or equal) for android

I'm attempting to react to a size change in my app. Or more specifically I'm trying to figure out when the keyboard shows up.
I've tried #Override ... onSizeChanged() of the main windows (a RelativeLayout view extension)
It gets called when I change the orientation, but not when I show/hide the keyboard.
My layout is not scrolling, so the controls at the top of my screen fall out of view, and the only way to get them back is to hide the keyboard.
I've read a pile of other sites and googled the snot out of this one, but it has me befuddled.
Oh.. I'm on a 2.1 (aka 7) build of android, and I'd like to be able to run the app on my own phone :)
Oh.. so the question. How do I catch something resembling onSize on an android device.
Try to add below to related activity in manifest.xml
android:windowSoftInputMode="adjustPan"
For Example
<activity android:name=".SignUp"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY" />
</intent-filter>
</activity>

Set orientation to landscape in android on both sides [duplicate]

This question already has answers here:
How can I rotate display only in landscape mode in android?
(4 answers)
Closed 6 months ago.
I am working in an android application in 2.2 and I want to set my application in landscape mode.
For that I added in my manifest with every activity tag android:screenOrientation="landscape" and it worked fine.
But it comes only in one side. If I turn the device again upside down it fit in the same position in landscape mode. How can I have landscape mode in both the side of the device. Please help me.
Thanks in advance.
Try this
android:screenOrientation="reverseLandscape"
To get an Android application to display in landscape mode only, add this line to your Activity definition in the AndroidManifest.xml file:
android:screenOrientation="landscape"
For example, this is the definition for my main activity in the Android manifest file:
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Using this, I think it will help you
addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange);
function onOrientationChange(event:StageOrientationEvent):void {
trace("onOrientationChange:"+event.afterOrientation);
...and process result.
}
}

Categories

Resources