title: How to wait for the child activity to finish
body: <p>I am trying to make a phonegap/cordova plugin which is for converting speech to text using  RecognizerIntent. The following is my code of the plugin class:</p>
  
  <pre><code>public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
      this.callbackContext = callbackContext;
      try {
          if (ACTION_INVOKE_SPEECH_RECOG.equals(action)) { 
  
              //JSONObject arg_object = args.getJSONObject(0);
  
              Intent calIntent =  new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
              calIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
              this.cordova.setActivityResultCallback(SpeechToTextPlugin.this);
              this.cordova.getActivity().startActivityForResult(calIntent,REQUEST_CODE );
              callbackContext.success("Completed Main Activity");
  
          }
          callbackContext.error("Invalid action");
          return false;
         } catch(Exception e) {
             System.err.println("Exception: " + e.getMessage());
             callbackContext.error(e.getMessage());
             return false;
  
      } 
  }
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (resultCode == Activity.RESULT_OK) {
            JSONObject obj = new JSONObject();
  
            try {
                //obj.put("TEXT", intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).toString());
                callbackContext.success(intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).toString());
  
            }catch(JSONException e){
  
            }
            super.onActivityResult(requestCode, resultCode, intent);
        }
  }
  </code></pre>
  
  <p>I pass the recognized text to the javascript invoking the execute method. Right now, after making a call to <code>startActivityForResult</code>, the execute function returns back. How do I pass the recognized word to the js?</p>