jammy jayaraj
jammy jayaraj

Reputation: 87

android + phonegap orientation problem

I am building an android application in phone gap. But when i change the orientation from portrait to landscape, i am getting the application from the beginning and not from where i was in the portrait view. how can i solve this issue ?

Upvotes: 5

Views: 5745

Answers (2)

Joe B
Joe B

Reputation: 596

Were you using the tutorial?? If so, I apologize for the error. Android WebView by default re-loads the configuration when you change the orientation, and we do specify it in the manifest file:

<activity android:name=".YourAppName"
              android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">

The change above will not be required, because PhoneGap already has that. Unfortunately, the tutorial doesn't tell you to copy over the entire Android Manifest over and just specifies the permissions. In my opinion, this setting is critical to to having a working application that doesn't reset the state every time the WebView resizes itself.

Upvotes: 9

Swapna
Swapna

Reputation: 2235

This is how to fix this problem in android, when orientation changes, activity gets restarted, OnCreate() method gets called. To avoid this specify this in the manifest file for the Activity

Override the following method in Activity class.

public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }

Upvotes: 1

Related Questions