原因:在Flutter中,安卓14熄屏后app黑屏可能是因为系统在省电模式下限制了CPU的使用,导致应用无法更新屏幕显示。
解决方法:在AndroidManifest.xml
中为你的Activity
添加android:keepScreenOn
属性。
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:keepScreenOn="true"
android:screenOrientation="portrait">
...
</activity>