Sub EnableProximityMonitoring As Boolean
Dim no As NativeObject
no = no.Initialize("UIDevice").RunMethod("currentDevice", Null)
no.SetField("proximityMonitoringEnabled", True)
Return no.GetField("proximityMonitoringEnabled").AsBoolean
End Sub
Sub GetProximityState As Boolean
Dim no As NativeObject
no = no.Initialize("UIDevice").RunMethod("currentDevice", Null)
Return no.GetField("proximityState").AsBoolean
End Sub
EnableProximityMonitoring returns true if proximity sensor is supported.
You can then check GetProximityState to get the state. Note that the screen will turn off automatically once you call EnableProximityMonitoring and the proximity sensor state is true.