AVAILABLE: 5
Hi guys, this time I want to share my experience in overcoming the official Android bug caused by these Indian guys.
It seems like they are starting to ignore the negative impacts caused by their innovations, whereas in the era before being dominated by Indians, Android looked elegant and smooth from time to time in every development.. but this time, there are so many damn bugs that I found and I have to use shamanic knowledge to overcome them, one of which is related to:
override fun onSaveInstanceState (outState: Bundle)
override fun onRestoreInstanceState (savedInstanceState: Bundle)
How could it not be, I found this bug on May 20, 2024 after our client complained about the unusual UX.
Finally I concluded myself that both overrides have been removed from the Android lifecycle, so what can I do, I have to use a manual method to save the UI state that I want.
Step 1 - Initialize Variable Bundle via onCreated
class Abc : Activity{ private var savedSate: Bundle? = null override fun onCreate (savedInstanceState: Bundle?) { //initialize here savedSate = savedInstanceState } }
Step 2 - Save Your UI State
private fun saveUIState (){ rvState = listManager?.onSaveInstanceState() rvStateChild = childManager?.onSaveInstanceState() savedSate?.putParcelable(RV_STATE, rvState) savedSate?.putParcelable(RV_STATE_CHILD, rvStateChild) }
Step 3 - Restore Your UI State
private val prepareHistoryDetail = Observer<ResponseWeeklyReportMkt> { rvState?.let { listManager?.onRestoreInstanceState(rvState) } }