I found that sometimes the message_received sub is repeating itself or there is the problem someplace else and I do not know where . The fact is that i send a sms and the code below speaks the body message 3 times in a row?
Strage but yet must be explanation ?
Strage but yet must be explanation ?
B4X:
Sub Process_Globals
dim hsmes as smsinterceptor
end sub
Sub Service_Create
hsmes.Initialize2("hsmes",999)
end sub
B4X:
Sub hsmes_MessageReceived (From As String, Body As String) As Boolean
Try
If Main.cid Then
If parse_blac.stopsms(From) Then
Log("mesajul a fost blocat")
Return True
End If
End If 'end main.cid
Catch
log_generator("sms_received0")
End Try
'***********************************************
Try
wait.Enabled=True
busy=True
asteapta.Enabled=True
Main.news=True ' anunta mesaj nou
Dim fromtemp As String
fromtemp="Id= , ThreadId= , Personid= , Date="&DateTime.Now&", Read= , Type=, Body="& Body &", Address="&From
'newmes.Add(fromtemp) ' creaaza lista
If IsPaused(Main)=True Then 'daca nu lucrez la ceva
Main.telefon=From
CallSubDelayed(Main,"destinatar") 'copiaza contactul
Else ' citeste mesajele si goleste lista de mesaje
If car OR carmode=1 Then
Main.telefon=From
CallSubDelayed(Main,"destinatar")
End If
End If
Catch
log_generator("sms_received1")
End Try
'************************************************************
Try
If Main.citire AND Main.TTS1.IsInitialized Then 'AND stopcit=False Then '?hs
If Main.cid=True AND parse_blac.stopread(From) Then
'daca sunt active blocarile si from se gaseste in blac list
'nu citeste nimic
Log("bloc read sms")
'donothing
Else
If Main.tech.GetContactNamebyPhone(From).Length>0 Then 'daca contactul este regasit in agenda
If astbol=False Then'delay citire mesaj lung
astbol=True
Main.TTS1.speak("Mesaje noi ",False)
Main.TTS1.speak(Main.tech.GetContactNamebyPhone(From),False)
Log("mesaje noi")
End If
If carmode=1 Then ' DACA ON ATUNCI CITESTE TOT TIMPUL CONTINUTUL MESAJULUI
Main.TTS1.speak(Body,False)
Else If car AND carmode <> 2 Then ' daca sunt pe auto iar car este true
Main.TTS1.speak(Body,False)
End If
Else 'daca nu este regasit in agenda
If astbol=False Then
astbol=True
Main.TTS1.speak("Mesaj nou",False)
End If
End If 'end of contact gasit in agenda
End If 'end of blocari
End If 'main.citire si tts initialised
Catch
log_generator("sms_received2")
End Try
End Sub