Manos Rasidakis
Manos Rasidakis

Reputation: 3

Activity orientation change while in the background

The first activity(locked portrait orientation) has 2 buttons that both open the second activity but A button opens it in portrait and B button opens it in landscape orientation.

The problem is that when B button opens the second activity (which is in dialog configuration and the first activity is shown in the background) the first activity changes orientation with the second one, thus restarting.

The question is, A) Can i prevent first activity from changing orientation and B) Can i disable orientation change animation so that the screen doesn't look like turning from portrait to landscape but just becoming landscape instead?

P.S For the A) question i know how to use saved state but i want to avoid it.

Upvotes: 0

Views: 365

Answers (1)

Rohan Lodhi
Rohan Lodhi

Reputation: 1395

Use Below Code in Manifest:

android:configChanges="keyboardHidden|orientation|screenSize" 
 android:screenOrientation="portrait"

Edited: Sorry there is no way to control the rotation animation. This is done way outside of your app, deep in the window manager where it takes a screenshot of the current screen, resizes and rebuilds the UI behind it, and then runs a built-in animation to transition from the original screenshot to the new rebuilt UI. There is no way to modify this behavior when the screen rotation changes

Upvotes: 1

Related Questions