在近期的工作中,报出了这一异常导致程序直接崩溃,经多方查阅
2021-06-18 14:17:46.325 15201-15201/com.icbc.im E/ActivityInjector: get life cycle exception
java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction
at android.app.ActivityInjector.checkAccessControl(ActivityInjector.java:24)
at android.app.Activity.onResume(Activity.java:1854)
at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:485)
at com.icbc.im.ui.activity.BaseActivity.onResume(BaseActivity.java:189)
at com.icbc.chat.activity.WebViewActivity.onResume(WebViewActivity.java:3343)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
at android.app.Activity.performResume(Activity.java:8051)
是因为小米的MIUI11/12主题切换 具体解释如下:
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.
给到的建议是:
Just goto values.xml and place this in your AppTheme
进入values.xml中并把<item name="android:forceDarkAllowed" >false</item> 添加到AppTheme中。
再次记录一下以便后续工作。