I had to put a try catch in this function as is fails on a new device we got from china. Just thought you should know.
B4X:
Sub IsNightMode As Boolean
Dim ctxt As JavaObject
Try
ctxt.InitializeContext
Log(ctxt.RunMethodJO("getResources", Null).RunMethodJO("getConfiguration", Null).GetField("uiMode"))
Return Bit.And(ctxt.RunMethodJO("getResources", Null).RunMethodJO("getConfiguration", Null).GetField("uiMode"), 0x30) = 0x20
Catch
Return False
End Try
End Sub
Alas, there is no error text available, if there was I would have posted it. I had to run it debug mode and the app stops on the log line. BTW its running Android 6.0