我有一个如下定义的全屏幕肖像活动。
在清单中:
<activity
android:name=".CameraActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</activity>
和
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
此活动的OnCreate
方法只调用带有YES和NO按钮的警告框。我的问题是,当手机处于横向状态时,警报框会崩溃,我会在下面显示泄露的窗口错误。
12-06 15:26:01.590: E/WindowManager(6286): Activity com.eyepax.rdms.CameraActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4058c508 that was originally added here
12-06 15:26:01.590: E/WindowManager(6286): android.view.WindowLeaked: Activity com.eyepax.rdms.CameraActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4058c508 that was originally added here
12-06 15:26:01.590: E/WindowManager(6286): at android.view.ViewRoot.<init>(ViewRoot.java:277)
12-06 15:26:01.590: E/WindowManager(6286): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
12-06 15:26:01.590: E/WindowManager(6286): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-06 15:26:01.590: E/WindowManager(6286): at android.view.Window$LocalWindowManager.addView(Window.java:433)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.Dialog.show(Dialog.java:288)
12-06 15:26:01.590: E/WindowManager(6286): at com.eyepax.rdms.CameraActivity$CameraTask.onPreExecute(CameraActivity.java:177)
12-06 15:26:01.590: E/WindowManager(6286): at android.os.AsyncTask.execute(AsyncTask.java:391)
12-06 15:26:01.590: E/WindowManager(6286): at com.eyepax.rdms.CameraActivity.onActivityResult(CameraActivity.java:127)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.Activity.dispatchActivityResult(Activity.java:4094)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.deliverResults(ActivityThread.java:2905)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2436)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2481)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1847)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3288)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.access$1600(ActivityThread.java:132)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1042)
12-06 15:26:01.590: E/WindowManager(6286): at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 15:26:01.590: E/WindowManager(6286): at android.os.Looper.loop(Looper.java:143)
12-06 15:26:01.590: E/WindowManager(6286): at android.app.ActivityThread.main(ActivityThread.java:4268)
12-06 15:26:01.590: E/WindowManager(6286): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 15:26:01.590: E/WindowManager(6286): at java.lang.reflect.Method.invoke(Method.java:507)
12-06 15:26:01.590: E/WindowManager(6286): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-06 15:26:01.590: E/WindowManager(6286): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-06 15:26:01.590: E/WindowManager(6286): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:3)
这是因为当设备转为LANDSCAPE
模式时,将重新创建活动。所以它抛出了窗口坏标记。
只需尝试在清单中添加以下代码行。
android:configChanges="keyboardHidden|orientation"