java.lang.IllegalStateException:SinchClient未启动

时间:2018-06-04 19:40:55

标签: android sinch android-sinch-api

我正在按照教程(https://www.sinch.com/tutorials/android-app-to-app-voip-tutorial/)开发Android应用到应用语音呼叫功能。

请告诉我解决此问题的建议。

由于 亚洲时报Siddharth

场景详情

  1. 对于调用方,我通过本教程创建了一个应用程序:github.com/sinch/app-app-calling-android。

  2. 对于接收方,我使用了示例应用程序sinch-android-rtc-3.12.5 / samples / sinch-rtc-sample-calling

  3. 我确保了Key / Secret&环境是双方匹配的

  4. 致电&正常接收应用程序构建和启动

  5. 我一直在Calling Side上获得此异常:

    E / AndroidRuntime:致命异常:主要                   过程:com.sinch.workshopskeleton,PID:24797                   java.lang.IllegalStateException:SinchClient未启动                       at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.throwUnlessStarted(Unknown Source)                       在com.sinch.android.rtc.internal.client.calling.DefaultCallClient.call(未知来源)                       at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(Unknown Source)                       at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(Unknown Source)                       at com.sinch.apptoappcall.CallActivity $ 1.onClick(CallActivity.java:67)                       在android.view.View.performClick(View.java:5612)                       在android.view.View $ PerformClick.run(View.java:22285)                       在android.os.Handler.handleCallback(Handler.java:751)                       在android.os.Handler.dispatchMessage(Handler.java:95)                       在android.os.Looper.loop(Looper.java:154)                       在android.app.ActivityThread.main(ActivityThread.java:6123)                       at java.lang.reflect.Method.invoke(Native Method)                       在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:867)                       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

    在课程中的以下UNDERLINED代码片段中 com.sinch.apptoappcall.CallActivity =>

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (call == null) {
    call = sinchClient.getCallClient().callUser(recipientId);  
    call.addCallListener(new SinchCallListener());
    button.setText("Hang Up");
    } else {
    call.hangup();
    }
    }
    });
    

1 个答案:

答案 0 :(得分:1)

你应该在调用 sinchClient.start() 之前添加这个来检查 sinch 是成功启动还是失败

    sinchClient.addSinchClientListener(this)
    override fun onClientStarted(p0: SinchClient?) {
        Timber.d("Sinch Client Started")
    }

    override fun onClientStopped(p0: SinchClient?) {
        Timber.d("Sinch Client Stopped")
    }

    override fun onClientFailed(p0: SinchClient?, p1: SinchError?) {
        Timber.d("Sinch Client Failed")
        /// You should add logic to re-start sinch client here
    }

    override fun onRegistrationCredentialsRequired(
        p0: SinchClient?,
        p1: ClientRegistration?
    ) {
        Timber.d("Sinch Client Credential Required")
    }

    override fun onLogMessage(p0: Int, p1: String?, p2: String?) {
        Timber.d(p1, p2)
    }

您可以阅读参考here