作为开发人员,我有什么方法可以防止 Phone 夜间模式设置强行关闭我的应用程序?
Any way for me as developer to prevent that Phone Nightmode setting closes my App forcefully?
抱歉,我不能更具体地说明这个话题。
我正在寻找问题的可能线索,如果有开发人员已知的解决方案:
许多常用设备,如 Samsung Galaxy S8/S9/S10,都有夜间模式 setting/Dark 主题设置。
我注意到切换此设置会无缘无故地强制关闭许多游戏应用程序进程,而其他游戏运行时不受该设置的影响。
作为开发人员,我对此有任何控制权吗?
Google Play apps by Nitrome,"Redungeon","Tower Fortress" 会在打开或关闭夜间模式时强行关闭,但我测试过的所有使用 Unity 引擎运行的应用程序都不会受到影响。
我假设发生这种情况是因为切换到暗模式会触发配置更改。配置更改将导致重新创建 activity,除非您明确告诉 OS 您将自己处理更改,如 here.
所述
When the app’s theme changes (either through the system setting or
AppCompat) it triggers a uiMode configuration change. This means that
Activities will be automatically recreated.
作为开发人员,您需要将清单中的 android:configChanges="uiMode"
添加到游戏的 activity 中,以防止 OS 更改主题时强制重新创建。
<activity
android:name=".MyActivity"
android:configChanges="uiMode" />
我不是 Unity 开发人员,但我假设 unity 默认会忽略所有配置更改。
抱歉,我不能更具体地说明这个话题。 我正在寻找问题的可能线索,如果有开发人员已知的解决方案: 许多常用设备,如 Samsung Galaxy S8/S9/S10,都有夜间模式 setting/Dark 主题设置。 我注意到切换此设置会无缘无故地强制关闭许多游戏应用程序进程,而其他游戏运行时不受该设置的影响。 作为开发人员,我对此有任何控制权吗? Google Play apps by Nitrome,"Redungeon","Tower Fortress" 会在打开或关闭夜间模式时强行关闭,但我测试过的所有使用 Unity 引擎运行的应用程序都不会受到影响。
我假设发生这种情况是因为切换到暗模式会触发配置更改。配置更改将导致重新创建 activity,除非您明确告诉 OS 您将自己处理更改,如 here.
所述When the app’s theme changes (either through the system setting or AppCompat) it triggers a uiMode configuration change. This means that Activities will be automatically recreated.
作为开发人员,您需要将清单中的 android:configChanges="uiMode"
添加到游戏的 activity 中,以防止 OS 更改主题时强制重新创建。
<activity
android:name=".MyActivity"
android:configChanges="uiMode" />
我不是 Unity 开发人员,但我假设 unity 默认会忽略所有配置更改。