code: private void sendRequest() {
  
          final String queryString = !eventSpinner.isEnabled() ? String.valueOf(queryEditText.getText()) : null;
          final String eventString = eventSpinner.isEnabled() ? String.valueOf(String.valueOf(eventSpinner.getSelectedItem())) : null;
          final String contextString = String.valueOf(contextEditText.getText());
  
          if (TextUtils.isEmpty(queryString) && TextUtils.isEmpty(eventString)) {
              onError(new AIError(getString(R.string.non_empty_query)));
              return;
          }
  
          final AsyncTask<String, Void, AIResponse> task = new AsyncTask<String, Void, AIResponse>() {
  
              private AIError aiError;
  
              @Override
              protected AIResponse doInBackground(final String... params) {
                  final AIRequest request = new AIRequest();
                  String query = params[0];
                  String event = params[1];
  
                  if (!TextUtils.isEmpty(query))
                      request.setQuery(query);
                  if (!TextUtils.isEmpty(event))
                      request.setEvent(new AIEvent(event));
                  final String contextString = params[2];
                  RequestExtras requestExtras = null;
                  if (!TextUtils.isEmpty(contextString)) {
                      final List<AIContext> contexts = Collections.singletonList(new AIContext(contextString));
                      requestExtras = new RequestExtras(contexts, null);
                  }
  
                  try {
                      return aiDataService.request(request, requestExtras);
                  } catch (final AIServiceException e) {
                      aiError = new AIError(e);
                      return null;
                  }
              }
  
              @Override
              protected void onPostExecute(final AIResponse response) {
                  if (response != null) {
                      onResult(response);
                  } else {
                      onError(aiError);
                  }
              }
          };
  
          task.execute(queryString, eventString, contextString);
      }
docs: /*
  AIRequest should have query OR event