3

I am new to android development. I have developed one app, now the problem is that whenever I rotate screen, app starts activity again and then its crashes application. I found some solution on google to use android:configChanges="orientation" . It works fine but when I rotate screen, its screen size does not change. How to solve this problem ?

Logact :

05-28 14:32:52.038: E/AndroidRuntime(276): FATAL EXCEPTION: main 05-28 14:32:52.038: E/AndroidRuntime(276): java.lang.IllegalArgumentException: View not attached to window manager 05-28 14:32:52.038: E/AndroidRuntime(276): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.view.Window$LocalWindowManager.removeView(Window.java:432) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.Dialog.dismissDialog(Dialog.java:278) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.Dialog.access$000(Dialog.java:71) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.Dialog$1.run(Dialog.java:111) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.Dialog.dismiss(Dialog.java:268) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.Dialog.cancel(Dialog.java:951) 05-28 14:32:52.038: E/AndroidRuntime(276): at com.MobileWeb.mytestbuddy.PremiumMain$TheTask.onPostExecute(PremiumMain.java:373) 05-28 14:32:52.038: E/AndroidRuntime(276): at com.MobileWeb.mytestbuddy.PremiumMain$TheTask.onPostExecute(PremiumMain.java:1) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.os.AsyncTask.finish(AsyncTask.java:417) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.os.AsyncTask.access$300(AsyncTask.java:127) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123) 05-28 14:32:52.038: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627) 05-28 14:32:52.038: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method) 05-28 14:32:52.038: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521) 05-28 14:32:52.038: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 05-28 14:32:52.038: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-28 14:32:52.038: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)

4

2 回答 2

40

您可以通过在应用程序的清单文件中添加以下内容来避免重新创建活动。

android:configChanges="orientation|keyboardHidden|screenSize"

如下

      <activity
        android:name=".your activity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name" >
    </activity>
于 2013-05-28T09:11:56.447 回答
-2

你的问题太模糊了。我只能说您需要检查您的日志猫并阅读并了解您的应用程序崩溃的原因。

我建议 从这里快速阅读 android:configChanges。希望这对您有所帮助。

于 2013-05-28T09:10:44.020 回答