Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Dim lv As LayoutValues = GetRealSize
Dim jo333 As JavaObject = Activity
jo333.RunMethod("setBottom", Array(lv.Height))
jo333.RunMethod("setRight", Array(lv.Width))
Activity.Height = lv.Height
Activity.Width = lv.Width
End Sub
Sub GetRealSize As LayoutValues
Dim lv As LayoutValues
Dim po As Phone
If po.SdkVersion >= 17 Then
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim display As JavaObject = ctxt.RunMethodJO("getSystemService", Array("window")).RunMethod("getDefaultDisplay", Null)
Dim point As JavaObject
point.InitializeNewInstance("android.graphics.Point", Null)
display.RunMethod("getRealSize", Array(point))
lv.Width = point.GetField("x")
lv.Height = point.GetField("y")
'''Add android:windowLayoutInDisplayCutoutMode = never in manifest if you don't want to use notch area
'''Add android:windowLayoutInDisplayCutoutMode = shortEdges in manifest if you want to use notch area
Dim r As Rect
r.Initialize(0,0,0,0)
Dim WindowVisibleDisplayFrame As JavaObject = ctxt.RunMethodJO("getWindow", Null)
WindowVisibleDisplayFrame = WindowVisibleDisplayFrame.RunMethodJO("getDecorView", Null)
WindowVisibleDisplayFrame = WindowVisibleDisplayFrame.RunMethodJO("getWindowVisibleDisplayFrame",Array(r))
If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
lv.Width = lv.Width - r.left
Else
lv.Height = lv.Height - r.top
End If
Else
lv.Width = 100%x
lv.Height = 100%y
End If
lv.Scale = 100dip / 100
Return lv
End Sub
Sub Activity_WindowFocusChanged(HasFocus As Boolean)
If HasFocus Then
Try
Dim jo As JavaObject = Activity
Sleep(300)
jo.RunMethod("setSystemUiVisibility", Array As Object(5894)) '3846 - non-sticky
Catch
'Log(LastException) 'This can cause another error
End Try 'ignore
End If
End Sub