MIUI 11/12 Theme Switch Results in LifeCycleException, ClassCastException
问题 Since MIUI 11/12 Use Its Own Custom Implementation of Dark Mode, using below code results in ClassCastException and Activity Life Cycle Exception, as DefaultNightMode and LocalNightMode is always Unspecified i.e. -100 instead of 0 or 1. If anyone has built a workaround for Xiaomi Devices specially for MIUI 11/12. Please Help Me Out On this. Code Used: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); this.recreate(); Error Caused: 2020-10-25 07:04:43.626 9167-9167/com