我的应用程序在横向模式下运行。当我的手机进入睡眠状态时,onDestroy()然后onCreate()被自动调用.i已经声明android:configChanges =“orientation “和android:screenOrientation =”landscape“。请告诉我该怎么做,以避免此问题。 我也附上了下面的xml文件。当睡眠按钮被按下时,onDestroy和onCreate被调用
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="m.example.ghb1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="m.example.ghb1.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PlayActivity"
android:configChanges="orientation"
android:screenOrientation="landscape"
>
</activity>
</application>
</manifest>
和哪里是问题? – Opiatefuchs
按睡眠按钮,你的意思是'显示关'按钮? – Sundeep