在Android

时间:2017-05-04 06:48:29

标签: android salesforce livechat

我们正在Android移动应用程序中实施salesforce live agent聊天。一切正常。但我们有一个角落案例。

发起聊天 - >打开聊天窗口 - >立即点击窗口中的关闭按钮[在几分之一秒内]。应用程序将崩溃。以下是从崩溃中获得的日志。

记录:

  

java.lang.NullPointerException:会话未激活。无法   创建LiveAgent请求。在   com.salesforce.android.service.common.utilities.validation.Arguments.checkNotNull(Arguments.java:75)     在   com.salesforce.android.chat.core.internal.liveagent.request.InternalChatRequestFactory.checkSessionIsActive(InternalChatRequestFactory.java:104)     在   com.salesforce.android.chat.core.internal.liveagent.request.InternalChatRequestFactory.createEndRequest(InternalChatRequestFactory.java:95)     在   com.salesforce.android.chat.core.internal.liveagent.handler.EndHandler.onEndingSessionState(EndHandler.java:109)     在   com.salesforce.android.chat.core.internal.liveagent.LiveAgentChatSession.onStateChanged(LiveAgentChatSession.java:177)     在   com.salesforce.android.chat.core.internal.liveagent.LiveAgentChatSession.onStateChanged(LiveAgentChatSession.java:54)     在   com.salesforce.android.service.common.utilities.lifecycle.LifecycleEvaluator.stateChanged(LifecycleEvaluator.java:304)     在   com.salesforce.android.service.common.utilities.lifecycle.LifecycleStateWatcher $ 1.run(LifecycleStateWatcher.java:73)     在android.os.Handler.handleCallback(Handler.java:751)at   android.os.Handler.dispatchMessage(Handler.java:95)at   android.os.Looper.loop(Looper.java:154)at   android.app.ActivityThread.main(ActivityThread.java:6688)at   java.lang.reflect.Method.invoke(Native Method)at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1468)     在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

是否有任何解决方法可以解决这个问题。感谢帮助。

1 个答案:

答案 0 :(得分:0)

这就是我在我这样做的方式。希望这会有所帮助。

WebView wvBody = (WebView) findViewById(R.id.Chat_wvBody);

String url = "http://myweburl.com/chatx.html?m_email=" + accountInfo.getUserEmail() +
            "&fname=" + accountInfo.getUserFirstName() +
            "&lname=" + accountInfo.getUserLastName();

    wvBody.getSettings().setJavaScriptEnabled(true);
    wvBody.getSettings().setSaveFormData(false);
    wvBody.getSettings().setDomStorageEnabled(true);
    wvBody.getSettings().setBuiltInZoomControls(false);
    wvBody.getSettings().setSupportZoom(false);
    wvBody.getSettings().setLoadWithOverviewMode(true);
    wvBody.getSettings().setUseWideViewPort(false);

    if (Build.VERSION.SDK_INT >= 21) {
        wvBody.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    wvBody.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap facIcon) {
            avLoadingIndicatorView.setVisibility(View.VISIBLE);
            tvNote.setVisibility(View.VISIBLE);
            //SHOW LOADING IF IT ISNT ALREADY VISIBLE
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            avLoadingIndicatorView.setVisibility(View.GONE);
            tvNote.setVisibility(View.GONE);
            //HIDE LOADING IT HAS FINISHED

            webViewLoadingFinished = true;
        }
    });

    if (savedInstanceState != null)
        wvBody.restoreState(savedInstanceState);
    else
        wvBody.loadUrl(url);

    wvBody.setBackgroundColor(0x00000000);