I found the exact problem. Now I need a solution
So first of all, the problem was because I wanted to try DayNight of appcompat in manifest,but apparently, B4A or B4X does not support
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowFullscreen">true</item>
</style>
</resources>
)
Now I need an alternative to this method.
For more details:
I use this Sub for dark mode:
Sub IsDarkModeEnabled As Boolean
Dim jo As JavaObject
jo.InitializeContext
Dim Them As String = Setting.GetString("darktheme")
If Them = "dark" Then
Return True
Else If Them = "light" Then
Return False
Else If Them = "default" Then
Try
Dim uiModeManager As JavaObject = jo.RunMethod("getSystemService", Array("uimode"))
Dim nightMode As Int = uiModeManager.RunMethod("getNightMode", Null)
Return nightMode = 2 ' MODE_NIGHT_YES
Catch
Log("Error checking system dark mode: " & LastException.Message)
Return False
End Try
Else
Setting.SetString("darktheme", "default")
Return False
End If
End Sub
which it works everywhere except on Main for some reason. That is the part I need help with.