Hi,
i've a strange behaviour with the SpeechToText (but also with SpeechRecognizer) library into a service
the service is started in a only one point when the user click the start button in the activity main
the problem is that, with only some LG devices (for example LG G2 and LG G3) when the application starts, run automatically the speech recognizer into service without click the start button
in the manifest there isn't a intent that starts the service
Why starts this service when application run
i try to debug but nothing. the log do not trace the line "** Service (servicespeechrecogn) Created **"
the code of the service:
Why starts this service when application run
I try to debug but nothing. the log do not trace the line "** Service (servicespeechrecogn) Created **"
Do you have some ideas why only with LG smartphone i have this behaviour?
i've a strange behaviour with the SpeechToText (but also with SpeechRecognizer) library into a service
the service is started in a only one point when the user click the start button in the activity main
the problem is that, with only some LG devices (for example LG G2 and LG G3) when the application starts, run automatically the speech recognizer into service without click the start button
in the manifest there isn't a intent that starts the service
Why starts this service when application run
i try to debug but nothing. the log do not trace the line "** Service (servicespeechrecogn) Created **"
the code of the service:
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim mSpeechRecong As SpeechToText
Dim mIntentSR As Intent
End Sub
Sub Service_Create
mSpeechRecong.Initialize("SpeechRecognition")
UpdateStatus("In preparazione...")
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim wLan As String = StateManager.GetSetting("language")
mIntentSR.Initialize("android.speech.action.VOICE_SEARCH_HANDS_FREE", "")
mIntentSR.PutExtra("android.speech.extra.LANGUAGE_MODEL", "free_form")
mIntentSR.PutExtra("calling_package", "com.breltolab.drivi")
mIntentSR.PutExtra("android.speech.extra.MAX_RESULTS", 5)
mIntentSR.PutExtra("android.speech.extras.SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS", 1000)
mIntentSR.PutExtra("android.speech.extras.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS", 2000)
mIntentSR.PutExtra("android.speech.extra.LANGUAGE_PREFERENCE", wLan)
mIntentSR.PutExtra("android.speech.extra.LANGUAGE", wLan)
mSpeechRecong.createSpeechRecognizer
mSpeechRecong.startListening(mIntentSR)
End Sub
Sub Service_Destroy
mSpeechRecong.cancel
mSpeechRecong.stopListening
mSpeechRecong.destroy
End Sub
Sub UpdateStatus(Message As String)
If IsPaused(Main) = False Then
CallSub2(Main, "SetLabelStatus", Message)
End If
End Sub
Sub SpeechRecognition_onReadyForSpeech
UpdateStatus("In ascolto...")
End Sub
Sub SpeechRecognition_onEndOfSpeech
UpdateStatus("Fine riconoscimento")
End Sub
Sub SpeechRecognition_onResults (results As Object)' Words As List)
Dim Words As List
Words.Initialize2(results)
Dim wListaOk(Words.Size) As String
Dim wSplitStr() As String
Dim wListaDrivi(Words.Size) As String
For I = 0 To Words.Size - 1
wSplitStr = Regex.Split(" ", Words.Get(I))
If wSplitStr.Length = 2 Then
wListaOk(I) = wSplitStr(0)
wListaDrivi(I) = wSplitStr(1)
End If
Next
If (Common.Contains(wListaOk, "ok") OR Common.Contains(wListaOk, "okay")) AND Common.Contains2(wListaDrivi, "drivi", 0.6) Then
If IsPaused(Main) Then
StartActivity(Main)
CallSubDelayed(Main, "StartAction")
Else
CallSub(Main, "StartAction")
End If
UpdateStatus("In colloquio...")
StopService("")
CancelScheduledService("")
Else
mSpeechRecong.StartListening(mIntentSR)
UpdateStatus("In ascolto...")
End If
End Sub
Sub SpeechRecognition_onRmsChanged (rms As Float)
If IsPaused(Main) = False Then
CallSub2(Main, "SetLabelRms", rms)
End If
End Sub
Sub SpeechRecognition_onEvent (EventType As Int)
End Sub
Sub SpeechRecognition_onPartialResults
UpdateStatus("Riconoscimento parziale")
End Sub
Sub SpeechRecognition_onBeginningOfSpeech
UpdateStatus("In riconoscimento...")
End Sub
Sub SpeechRecognition_onError (ErrorType As Int)
Select Case ErrorType
Case 1
UpdateStatus("Timeout delle operazioni di rete")
mSpeechRecong.startListening(mIntentSR)
Case 2
UpdateStatus("Errore di rete")
mSpeechRecong.startListening(mIntentSR)
Case 3
UpdateStatus("Errore audio")
Case 4
UpdateStatus("Errore server")
Case 5
UpdateStatus("Errore client")
Case 6
mSpeechRecong.startListening(mIntentSR)
Case 7
UpdateStatus("Nessuna corrispondenza trovata")
mSpeechRecong.startListening(mIntentSR)
Case 8
UpdateStatus("Servizio riconoscimento occupato")
mSpeechRecong.cancel
Case 9
UpdateStatus("Permessi insufficienti")
Case Else
UpdateStatus("Errore sconosciuto")
End Select
End Sub
Why starts this service when application run
I try to debug but nothing. the log do not trace the line "** Service (servicespeechrecogn) Created **"
Do you have some ideas why only with LG smartphone i have this behaviour?