问题
I'm using Google Cloud Platform Speech API. I'm developing using sample source. https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech
almost the same as sample source. except many start/stop of VoiceRecorder in my app.
I got this error in samsung devices. I didn't get this error in huawei devices.
com.google.common.base.Preconditions.checkState (Preconditions.java:444) io.grpc.internal.ClientCallImpl.sendMessage (ClientCallImpl.java:389) io.grpc.ForwardingClientCall.sendMessage (ForwardingClientCall.java:67) io.grpc.stub.ClientCalls$CallToStreamObserverAdapter.onNext (ClientCalls.java:302) com.example.myapp.SpeechService.recognize (SpeechService.java:299) com.example.myapp.MyActivity$1.onVoice (MyActivity.java:152) com.example.myapp.VoiceRecorder$ProcessVoice.run (VoiceRecorder.java:224)
Please help me if you have experienced the same problem. Thanks in advance.
回答1:
The error means you previously called onCompleted()
but are now calling onNext()
; that's not allowed.
The code in SpeechService.java
looks pretty reliable to avoid this sort of problem. My only guess is that you're using the class from multiple threads, but the class is not thread-safe.
来源:https://stackoverflow.com/questions/51358715/grpc-call-was-half-closed-error