android-studio - 重新创建();设置 AppCompatDelegate 后导致 ClassCast 异常
问题描述
如果我的介绍活动中的默认模式是暗模式,我正在尝试设置亮模式
介绍.java
if(AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO)
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
this.recreate();
}
但这会引发错误:
2020-10-25 07:04:43.626 9167-9167/com.xxxx.xxxxxx E/ActivityInjector: get life cycle exception
java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction
我在用
Theme.AppCompat.DayNight.NoActionBar
此外,主题不会在活动中更新。如果有人知道,请帮助我解决这个问题。
解决方案
推荐阅读
- python - Scipy 无法正确安装
- sql - 如何在不丢失重复值的情况下使两个表相交 oracle
- jboss7.x - 如何捕捉 org.jboss.weld.context.ContextNotActiveException
- sql-server - 将数据加载到具有固定长度 ssis 的 .txt 文件中
- arrays - 猫鼬添加到数组中没有重复和排序
- javascript - Babel 安装 - src 不存在
- android - 由于缺少设置,使用 avdmanager 创建的 AVD 不再启动
- ajax - 来自 Ajax 的 MVC Web Api 调用以 404 响应
- php - 在 PHP 中在 Sprintf 之外使用 %S
- python - 如何根据扩展名打开文件?