Issue
How do I avoid reloading the activity with asynctask class in activity when the user changes orientation, in android? Can anybody give an example?
Solution
Chirag have already correctly pointed out the solution.
I just want to add that, restart of Activity has nothing to do with the AsyncTask
in it. By default, when there are any config changes,the activity is restarted UNLESS the config change is explicitly handled by the Activity. This is done by making an entry in manifest file.
Go through this link developer guide : android:configChanges
NOTE: Check the code on a device not on emulator. Because I had faced similar problem earlier. The same code didn't worked on emulator but it worked on device perfectly. So add the entry for android:configChanges
in manifest and check the application on a android device instead of emulator.
And I second @hackbod. Do it only if necessary!
Answered By - Udayan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.