public void doSignUp(OnAddUpdateListener<SignUpValidationError> listListener, SignUpRequest request) {
mListener = listListener;
LeafApiClient apiClient = LeafApplication.getInstance().getApiClient();
LeafService service = apiClient.getService(LeafService.class);
final Call<SignUpResponse> model = service.signup(request);
ResponseWrapper<SignUpResponse> wrapper = new ResponseWrapper<>(model);
我在apiClient上遇到错误:无法在空对象引用上调用getApiClient()
private LeafApiClient apiClient;
private static LeafApplication sInstance;
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
sInstance = this;
public static LeafApplication getInstance(){
return sInstance;
}
public synchronized LeafApiClient getApiClient(){
if (apiClient == null){
apiClient = LeafApiClient.getInstance(getApplicationContext());
}
return apiClient;
}
这是我调用方法getApiClient
的代码