bala
bala

Reputation: 436

PhoneGap Android orientation change takes the app one page back

I'm developing a simple Android app on PhoneGap where the users can calculate their GPA's and CGPA's.

I sense something strange happening. Whenever the user tilts the screen and shifts from portrait to landscape mode, the app goes back to the previous page as if the back button was pressed.

This is how my manifest file looks,

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

    <uses-sdk
        android:minSdkVersion="4"
        android:targetSdkVersion="17" />
    <supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true"
    android:resizeable="true"
    android:anyDensity="true"
    />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" />
    <application
        android:configChanges="orientation|keyboardHidden"
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.firstVersion.MainActivity"
            android:label="@string/app_name" >
            android:launchMode="singleTop"
            <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>
         <receiver android:name="com.phonegap.plugin.localnotification.AlarmReceiver" >
        </receiver>

        <receiver android:name="com.phonegap.plugin.localnotification.AlarmRestoreOnBoot" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
         <receiver android:name="com.bicrement.plugins.localNotification.AlarmReceiver" >
  </receiver>

  <receiver android:name="com.bicrement.plugins.localNotification.AlarmRestoreOnBoot" >
      <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED" />
      </intent-filter>
  </receiver>


    </application>

</manifest>

Upvotes: 2

Views: 748

Answers (1)

Shashi
Shashi

Reputation: 1235

Add android:configChanges under each activity tag not in application tag as you written in application tag and skip it to MainActivity tag

Try This:-

  <activity
        android:name="com.example.firstVersion.MainActivity"
        android:configChanges="orientation|screenSize|keyboardHidden|keyboard|locale"
        android:label="@string/app_name">

Upvotes: 1

Related Questions