Sub hsmes_MessageReceived (From As String, Body As String) As Boolean
Dim state As Int 'v20
state=GetCallState
if state=0 then
'your code is safe to run here
end if
end sub
'returns the current device call state
'0 = Device call state: No activity.
'1 = Device call state: Ringing. A new call arrived and is ringing or waiting. In the latter case, another call is already active.
'2 = Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
Sub GetCallState() As Int
'v20
Dim r As Reflector
Dim TelephonyManager As Object
r.Target = r.GetContext
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
Return r.RunMethod( "getCallState")
End Sub