1

I have set my app's orientation to sensor and I am having the app handle all the orientation changes. Everything is working as expected while the app is running.

The problem occurs during the initial launch of the app. If the phone is in portrait mode and a user starts my app, I see my app background appear, then it will do an orientation rotation to landscape view, because I use setRequestedOrientation() within my app. I want the orientation change but I don't want the rotation animation that comes with it. I just want a hard switch between portrait and landscape.

I have tried using overridePendingTransition(0,0) in onCreate, surfaceChanged, or in onConfigurationChanged with no luck. Is there somewhere else I should put this? I believe that using (0,0) should disable the pending animation.

I get the desired effect if I set System Settings->Display->Animations to none. I have tried to set styles for my activity and that did not work either.

Stefan
  • 5,203
  • 8
  • 27
  • 51
user812525
  • 11
  • 2
  • I'm not sure I fully understand your question. Are you asking how to solve the problem when your app is initially launched? Or for a solution to a problem that happens through the entirety of your app? – Tyler Ferraro Jun 23 '11 at 15:56
  • Just when the app is initially launched. – user812525 Jun 23 '11 at 20:05
  • Would it be possible on the OnCreate of your app to set a global variable to 1, and in the onOrientationChange code check for that variable. If 1, don't let it reorientate. Then when your app is full loaded set that value to 0? Kind of like how multi-threading can lock certain code. – Tyler Ferraro Jun 23 '11 at 20:35
  • Were you able to disable rotation animation? If I understand you well, I'm facing same problem and it hasn't been solved by any answer or comment. I added this question before finding yours: http://stackoverflow.com/questions/11957772/ – Jorge Cevallos Aug 14 '12 at 20:35

1 Answers1

1

If the problem is only at application startup time, you can do this to force the landscape orientation with no animation:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp"
    android:versionCode="1"
    android:versionName="1.0"> 

    <application android:icon="@drawable/icon" 
                 android:label="@string/app_name">

        <activity android:name="com.example.myapp.MyActivity" 
                  android:screenOrientation="landscape">

        ...

        </activity>

    </application>
</manifest>  

And then you can programmatically change the android:screenOrientation setting later in the code to allow landscape and portatit if you would like to.

Shlublu
  • 10,917
  • 4
  • 51
  • 70