hi,

my app has a search function which when a button is clicked, it
creates a new dialog and then start a new background thread that
performs an asynchronous http request, when the http request is
finished, the background thread cancels the dialog and the data is
displayed on screen.

I notice however, if i change the orientation of the screen while the
background thread is running, the app will crash. The error log shows
the following:

W/dalvikvm(  292): threadid=3: thread exiting with uncaught exception
(group=0x40010e28)
E/AndroidRuntime(  292): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(  292): java.lang.IllegalArgumentException: View not
attached to window manager
E/AndroidRuntime(  292):        at
android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:
331)
E/AndroidRuntime(  292):        at
android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
E/AndroidRuntime(  292):        at android.view.Window
$LocalWindowManager.removeView(Window.java:401)
E/AndroidRuntime(  292):        at
android.app.Dialog.dismissDialog(Dialog.java:249)
E/AndroidRuntime(  292):        at android.app.Dialog.access
$000(Dialog.java:59)
E/AndroidRuntime(  292):        at android.app.Dialog
$1.run(Dialog.java:93)
E/AndroidRuntime(  292):        at
android.app.Dialog.dismiss(Dialog.java:233)
E/AndroidRuntime(  292):        at
android.app.Dialog.cancel(Dialog.java:838)
E/AndroidRuntime(  292):        at com.yellowbook.android2.SearchHelper
$3.handleMessage(SearchHelper.java:97)
E/AndroidRuntime(  292):        at
android.os.Handler.dispatchMessage(Handler.java:88)
E/AndroidRuntime(  292):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime(  292):        at
android.app.ActivityThread.main(ActivityThread.java:3742)
E/AndroidRuntime(  292):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  292):        at
java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(  292):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime(  292):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
E/AndroidRuntime(  292):        at
dalvik.system.NativeStart.main(Native Method)

Does anyone knows a better way to do async processing that wont crash
on orientation change?

Thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to