fix: enter immersive mode after setContentView to avoid DecorView NPE
This commit is contained in:
@@ -54,9 +54,13 @@ class MainActivity : Activity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
Log.d(TAG, "onCreate: enter immersive mode")
|
Log.d(TAG, "onCreate: setup webview then enter immersive mode")
|
||||||
enterImmersive()
|
// 先 setContentView 创建 DecorView,再进沉浸式;否则 window.insetsController 会
|
||||||
|
// 因 DecorView 尚未创建(null)而 NPE 崩溃
|
||||||
|
// Set content view first to create the DecorView, then enter immersive mode;
|
||||||
|
// otherwise window.insetsController throws NPE because DecorView is not created yet
|
||||||
setupWebView()
|
setupWebView()
|
||||||
|
enterImmersive()
|
||||||
checkNotificationAccess()
|
checkNotificationAccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user