集成 Helpshift API 时在 Android studio 中出现错误(空指针异常)
Getting an error in Android studio when integrating the Helpshift API (null pointer exception)
我在 Android 工作室中遇到空点异常。我正在尝试将 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 打开常见问题解答。
您缺少 API 的 InstallConfig
。尝试将其添加到呼叫 Activity 中。
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);
}
我在 Android 工作室中遇到空点异常。我正在尝试将 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 打开常见问题解答。
您缺少 API 的 InstallConfig
。尝试将其添加到呼叫 Activity 中。
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);
}