我正在開發平板電腦應用程序。一切正常,直到設備被鎖定。一旦設備被鎖定並旋轉,那麼強制關閉就會出現。當設備被鎖定,旋轉並重新鎖定時獲得強制關閉
我強迫我的應用程序運行在LANDSCAPE模式。所以我在清單中提到了這個許可。
<activity
android:name=".activity.LoginActivity"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
所以,當我鎖定我的設備和旋轉的再變的方向和該部隊密切產生。
要解決這個問題,我說在menifest此權限。
android:configChanges="orientation"
並在代碼:
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
Log.i("Log", "Configuration changes called");
int orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
// or = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
setRequestedOrientation(orientation);
}
我也加入了這一行的的onCreate()
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("Log", "OnCreate");
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.lyt_login_main);
........
}
但它仍然沒有得到解決。請幫我解決這個問題。
這是我收到的錯誤:
12-17 11:13:57.877: E/AndroidRuntime(10462): FATAL EXCEPTION: main
12-17 11:13:57.877: E/AndroidRuntime(10462): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.marico.icp/com.marico.icp.activity.LoginActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03000f
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3365)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.access$700(ActivityThread.java:128)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1165)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.os.Looper.loop(Looper.java:137)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.main(ActivityThread.java:4514)
12-17 11:13:57.877: E/AndroidRuntime(10462): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 11:13:57.877: E/AndroidRuntime(10462): at java.lang.reflect.Method.invoke(Method.java:511)
12-17 11:13:57.877: E/AndroidRuntime(10462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-17 11:13:57.877: E/AndroidRuntime(10462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-17 11:13:57.877: E/AndroidRuntime(10462): at dalvik.system.NativeStart.main(Native Method)
12-17 11:13:57.877: E/AndroidRuntime(10462): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03000f
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.content.res.Resources.getValue(Resources.java:1037)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2144)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.content.res.Resources.getLayout(Resources.java:870)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-17 11:13:57.877: E/AndroidRuntime(10462): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.Activity.setContentView(Activity.java:1835)
12-17 11:13:57.877: E/AndroidRuntime(10462): at com.marico.icp.activity.LoginActivity.onCreate(LoginActivity.java:77)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.Activity.performCreate(Activity.java:4465)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
12-17 11:13:57.877: E/AndroidRuntime(10462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
12-17 11:13:57.877: E/AndroidRuntime(10462): ... 12 more
在此先感謝。
那的活動,因爲你沒有在橫向模式 –
適當的資源ü的意思是說佈局,正確的? –
我已經創建了layout-large-land文件夾並在那裏保留了佈局。它的工作非常好,直到設備被鎖定。通過鎖定和解鎖也工作正常。但通過鎖定,旋轉設備和解鎖它給出了一個錯誤 –