在集成Helpshift API时在Android Studio中出错(空指针异常)

时间:2018-04-19 05:40:41

标签: android nullpointerexception helpshift

我在Android studio中遇到了零点异常。我正在尝试将Helpshift集成到我当前的应用程序中。我认为在帮助按钮上调用了零点。我得到的错误是:

java.lang.NullPointerException: Attempt to invoke interface method 
'void com.helpshift.CoreApi.updateApiConfig(java.util.Map)' on a null object reference

我的代码看起来像

package com.example.leoconnelly.connexus;




public class MainActivity extends AppCompatActivity {

ImageButton FindCareButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


//THE PURPLE BUTTON!!!!!!!
    FindCareButton = (findViewById(R.id.find_care_button));

    FindCareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openFindCare();
        }
    });

    /*
    GetStartedButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openSearchActivity();
        }
    });
     */

    ImageButton helpButton = (ImageButton) findViewById(R.id.imageButton13);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ApiConfig.Builder configBuilder = new ApiConfig.Builder();
            configBuilder.setRequireEmail(true);
            configBuilder.setEnableTypingIndicator(true);
            com.helpshift.support.Support.showConversation(MainActivity.this, configBuilder.build() );


        }
    });


}

public void openFindCare () {
   Intent mainActivityToFindCare = new Intent (this, 
HealthCenterListActivity.class);
    startActivity(mainActivityToFindCare);
}

}

我不确定它的指向是什么。我正在尝试从Helpshift打开常见问题解答。

1 个答案:

答案 0 :(得分:0)

您缺少API的InstallConfig。尝试在“呼叫活动”中添加它。

import com.helpshift.Core;
import com.helpshift.All;
import com.helpshift.InstallConfig;
import com.helpshift.exceptions.InstallException;

Core.init(All.getInstance());
        InstallConfig installConfig = new InstallConfig.Builder()
                .setEnableInAppNotification(true)
                .build();

        try {
            Core.install(getApplication(),
                    API_KEY,
                    DOMAIN,
                    APP_ID, installConfig);


        } catch (InstallException e) {
            android.util.Log.e("Helpshift", "install call : ", e);
        }