Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 486
jammy jayaraj Avatar asked Apr 04 '11 11:04

jammy jayaraj


2 Answers

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.

like image 88
Joe B Avatar answered Sep 21 '22 22:09

Joe B


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); }

like image 25
Swapna Avatar answered Sep 22 '22 22:09

Swapna