1

贝娄我的代码是登录 twilio 客户端正在工作

public void login(final String clientName,
                          final boolean allowOutgoing,
                          final boolean allowIncoming) {
            if (loginListener != null)
                loginListener.onLoginStarted();

            this.lastClientName = clientName;
            this.lastAllowOutgoing = allowOutgoing;
            this.lastAllowIncoming = allowIncoming;

            if (!twilioSdkInited) {
                if (twilioSdkInitInProgress)
                    return;

                twilioSdkInitInProgress = true;
                Twilio.setLogLevel(Log.DEBUG);

                Twilio.initialize(context, new Twilio.InitListener() {
                    @Override
                    public void onInitialized() {

                        Log.e(TAG, "onInitialized");
                        twilioSdkInited = true;
                        twilioSdkInitInProgress = false;
                        obtainCapabilityToken(clientName, allowOutgoing, allowIncoming);
                    }

                    @Override
                    public void onError(Exception error) {
                        Log.e(TAG, "onInitialized onError :" + error.toString());
                        Log.e(TAG, " onInitialized onError : isTokenExpired is Blank");
                        twilioSdkInitInProgress = false;

                        if (loginListener != null)
                            loginListener.onLoginError(error);
                    }

                    @Override
                    protected void finalize() throws Throwable {

                        Log.e(TAG, "@call finalize()");
                        if (device != null)
                            device.release();
                        if (connection != null)
                            connection.disconnect();
                        super.finalize();
                    }
                });
            } else {
                Log.e(TAG, "twilioSdkInited obtainCapabilityToken");
                obtainCapabilityToken(clientName, allowOutgoing, allowIncoming);
            }

以下日志是重新启动我的应用程序时生成的错误。

07-06 10:10:14.265 32611-32611/com.reach.communications E/NewCallScreenActivity: @call onLoginStarted
07-06 10:10:14.265 32611-32611/com.reach.communications I/PJSIP: 10:10:14.265 sip_endpoint.c !Module "mod-pjsua-log" unregistered
07-06 10:10:14.265 32611-32611/com.reach.communications I/PJSIP: 10:10:14.265 sip_endpoint.c  Module "mod-pjsua-log" registered
07-06 10:10:14.265 32611-32611/com.reach.communications E/BasicPhone: onInitialized onError :java.lang.RuntimeException: Twilio.initialize() already called
07-06 10:10:14.265 32611-32611/com.reach.communications E/BasicPhone:  onInitialized onError : isTokenExpired is Blank
07-06 10:10:14.265 32611-32611/com.reach.communications E/NewCallScreenActivity: @call onLoginError :java.lang.RuntimeException: Twilio.initialize() already called
07-06 10:10:14.265 32611-32611/com.reach.communications E/NewCallScreenActivity: @Call State idle

如果我收到此错误并重新登录客户端如何处理。或如何重新初始化 twilio。

onError(异常错误)

提前致谢

4

1 回答 1

1

我看你在努力.release()。如果使用该.shutdown()方法会发生什么?这将终止所有连接,释放所有设备对象,并释放 SDK 使用的任何资源。

然后,您可以.initialize()在下次通话之前安全地再次通话。

此外,您可以使用.isInitialized()来确定客户端是否准备好。

请让我知道这些更改是否有帮助。

于 2016-08-23T20:23:43.370 回答