/*
   * Encapsulate the result message and send back to apps
   *
   * @param message
   *
   * @param errorid
   */
  protected void sendMessageToApps(VoiceMessage message, int errorid) {
    Bundle bundle = null;

    if (errorid == VoiceCommandListener.VOICE_NO_ERROR) {
      bundle = DataPackage.packageSuccessResult();
    } else {
      bundle = DataPackage.packageErrorResult(errorid);
    }

    message.mExtraData = bundle;
    // Notify the apps about the execution result
    mDispatcher.dispatchMessageUp(message);
  }
 /*
  * Send all contacts name to next dispatcher
  *
  * @param contactsNameList contacts name list
  */
 public void handleAsyncContactsMsg(String[] contactsNames) {
   VoiceMessage message = new VoiceMessage();
   message.mMainAction = VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS;
   message.mSubAction = VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME;
   Bundle bundle = DataPackage.packageSendInfo(contactsNames, null);
   message.mExtraData = bundle;
   mVoiceContacts.handleAsyncVoiceMessage(message);
 }
Example #3
0
  private void sendToMainHandler() {
    Log.d(TAG, "[sendToMainHandler]...");
    if (mMainHandler.hasMessages(VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME)) {
      mMainHandler.removeMessages(VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME);
    }
    // Query database after remove the contacts msg of main handler
    String[] contactsNames = getContactsNames();
    VoiceMessage message = new VoiceMessage();
    message.mMainAction = VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS;
    message.mSubAction = VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME;
    Bundle bundle = DataPackage.packageSendInfo(contactsNames, null);
    message.mExtraData = bundle;

    Message msg = mMainHandler.obtainMessage();
    msg.what = VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS;
    msg.obj = message;
    mMainHandler.sendMessage(msg);
  }