My training application has a tab with 6-7 tabs that supports landscape and portrait modes. In each tab-related action, I show some student entries in a list view, some check boxes for selection, and some rating bars, buttons, etc. I get these student records from a remote server through a web service call. For some reason, my application will show one initial relative layout with some buttons after performing some actions / searches. It displays the results in a list by clicking on a list item or button in a list. I am showing another layout. This applies to all actions in the tab node.
If the user changes orientation, I need to restore the same state or the same screen if the user is viewing the list of records that I should display the list of records. If at first I should show only the initial ones. I do not want to force stop android destructive activity when changing orientation or overriding public Object onRetainNonConfigurationInstance () . As suggested on some blogs and in the android doc, this can cause problems in subsequent operations. What I did was simply save all the necessary information, such as screen 1 or 2 or 3, text-type labels and all the primitive data types in the onSaveInstanceState package and restore them to onRestoreInstanceState . I also write my custom search results. An object array for file and restore and delete it between onSaveInstanceState and onRestoreInstanceStates. Since my search results contain 100 objects, and I store huge volumes of lists of types of primitive data that quickly increase the size of the heap when the user quickly rotates the device.
What is the best way to handle this.
1) stored in onSaveInstanceState and onRestoreInstanceStates, which makes my screen blank for some time and increases the size of the heap, not necessarily performing a save and restore when the user rotates multiple times
2) by storing all the necessary data in some place where it is static, since it is not local to activity, it will not destroy
3) saving all the necessary data by extending the Application class?
android android-orientation
Ganesh K Jul 20 2018-12-12T00: 00Z
source share