3
I have a problem, an Activity of mine has a list of multi-selectable objects, with the long click I can select several of these objects and click the remove button, when I click to remove, appears a dialog Progress that runs by an Assynctask.
The problem is that when I change the orientation of the smartphone (either changes to Portrait or Landscape) the view is updated, and this causes the thread to stop causing an error, how do I prevent this error? Or prevent assynctask from stopping without fixing an orientation?
Error:
java.lang.IllegalArgumentException
WindowManagerGlobal.java line 372 in WindowManagerGlobal.findViewLocked()
android.view
WindowManagerGlobal.java line 372 in WindowManagerGlobal.findViewLocked()
android.view
WindowManagerGlobal.java line 301 in WindowManagerGlobal.removeView()
android.view
WindowManagerImpl.java line 84 in WindowManagerImpl.removeViewImmediate()
android.app
Dialog.java line 332 in Dialog.dismissDialog()
android.app
Dialog.java line 123 in Dialog$1.run()
android.os
Handler.java line 808 in Handler.handleCallback()
android.os
Handler.java line 103 in Handler.dispatchMessage()
android.os
Looper.java line 193 in Looper.loop()
android.app
ActivityThread.java line 5292 in ActivityThread.main()
vc has tried to use this statement in manifest.xml: android:configChanges="orientation|screenSize|Keyboard|keyboardHidden"
– Pedro Rangel
worked out, but according to Google, you should not do this, and my layout gets weird, especially the admob banner that is not changed since the view does not update, then it is small
– felipe.rce
Have you tried using a
AsyncTaskLoader
? As they you will not have problems with changing orientation, since their life cycle is managed byActivityManager
.– Wakim
cannot use async Loader, because besides using Progress dialog with Dismiss at the end, when this Dismiss runs, changes occur in the UI, well at least I do not know how to make changes inside the asynctaskloader... I don’t think so
– felipe.rce
maybe some way to block the rotation while the assync runs? this is possible?
– felipe.rce
Leave it, I blocked the screen even, I could not find a solution on google... But it would be good if someone responded by giving the example of this configChanges, or something else for me to accept here
– felipe.rce
Yes, it is possible to block the rotation of the screen while the
AsyncTask
is executed. I don’t know if it’s that bad, since she goes back to normal after... But using theAsyncTaskLoader
you would use the methodonLoadFinished
to update the interface, and then no matter if the orientation has changed, it will run in the nextActivity
(Assuming you started the update in which it was destroyed).– Wakim