Prevent change of orientation update Activity

3

I have a problem, an Activity my 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, a progress dialog appears that is executed by an AssyncTask .

The problem is that when I change the orientation of the smartphone (either it 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 having to set 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()
    
asked by anonymous 19.10.2014 / 08:01

1 answer

2

To solve this problem open the file AndroidManifest.xml , hence in the declaration of your activity add the following line:

android:configChanges="orientation|screenSize"

Example:

<activity
    android:name="com.example.activity.MainActivity"
    android:configChanges="orientation|screenSize"
    android:label="@string/app_name" >
</activity>
    
14.09.2015 / 15:33