Don't stop the theme change instead store your data in viewModels.
The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations or theme change.
Have a look : viewModel
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…