android - PhoneGap Android 方向更改使应用程序后退一页

标签 android cordova screen-orientation

我正在 PhoneGap 上开发一个简单的 Android 应用程序,用户可以在其中计算他们的 GPA 和 CGPA。

我感觉到有什么奇怪的事情发生了。每当用户倾斜屏幕并从纵向模式切换到横向模式时,应用程序都会返回到上一页,就像按下后退按钮一样。

这是我的 list 文件的样子,

<?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>

最佳答案

在每个不在应用程序标签中的 Activity 标签下添加android:configChanges,就像您在应用程序标签中编写的那样,然后将其跳到MainActivity标签

试试这个:-

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

关于android - PhoneGap Android 方向更改使应用程序后退一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17636982/

相关文章:

android - 从 FCM 通知访问、打开或编辑 Web View

javascript - 从 Android 手机的 phonegap 应用程序中的 url 解析 json

angularjs - ionic : no content/white screen using interceptors

android - 我可以在 android 中获取其他应用程序的可用屏幕方向吗?

android - 如何更改 Android 中 fragment 的方向?

android - 如何从默认应用程序播放YouTube视频

android - getActionBar 返回 null

java - 如何为Recyclerview中的所有imageView添加相同的onClick?

iphone - 如何在我的 &lt;input&gt; 上禁用 iPhone 的自动填充栏?

android - 为什么 `android:screenOrientation="后面"` 在 android 4.1.2 中没有效果?