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 ?
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.
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With