Friday, 27 April 2012

PhoneGap Android orientation.

My PhoneGap application exited when device orientation changed.
These code will solve the problem. Update AndroidManifest with the code as highlighted in the example. 


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".EStoryBooksActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
            android:name="org.apache.cordova.DroidGap" 
            android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden"> 
            
            <intent-filter> 
            </intent-filter> 
        </activity>
    </application>

For Android SDK 3.1 need to add screen size to the config.

android:configChanges="orientation|screenSize|keyboardHidden

No comments:

Post a Comment