Example #1
0
  // Receive the data from second activity when this is finished; Code similar from Hand In 1
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == 0) {
      try {
        txtNote.setText(data.getCharSequenceExtra("note"));
        txt = txtNote.toString();

      } catch (java.lang.RuntimeException e) {
        e.printStackTrace();
      }
    }
  }
  private boolean internalRegister(JSONArray data, CallbackContext callbackContext) {
    JSONObject params = null;
    try {
      params = data.getJSONObject(0);
    } catch (JSONException e) {
      e.printStackTrace();

      callbackContext.error(e.getMessage());
      return true;
    }

    callbackIds.put("registerDevice", callbackContext);

    try {
      String appid = null;
      if (params.has("appid")) appid = params.getString("appid");
      else appid = params.getString("pw_appid");

      mPushManager = new PushManager(cordova.getActivity(), appid, params.getString("projectid"));
    } catch (JSONException e) {
      callbackIds.remove("registerDevice");
      e.printStackTrace();

      callbackContext.error(e.getMessage());
      return true;
    }

    try {
      if (loggedStart) {
        mPushManager.onStartup(cordova.getActivity(), false);
      } else {
        mPushManager.onStartup(cordova.getActivity(), true);
        loggedStart = true;
      }
    } catch (java.lang.RuntimeException e) {
      callbackIds.remove("registerDevice");
      e.printStackTrace();

      callbackContext.error(e.getMessage());
      return true;
    }

    checkMessage(cordova.getActivity().getIntent());
    return true;
  }
Example #3
0
  /** Handle the message (as specified in the javax.jms.MessageListener interface). */
  @Override
  public void onMessage(javax.jms.Message aMessage) {
    try {
      // Cast the message as a text message.
      javax.jms.TextMessage textMessage = (javax.jms.TextMessage) aMessage;

      // This handler reads a single String from the
      // message and prints it to the standard output.
      try {
        String string = textMessage.getText();
        System.out.println(string);
      } catch (javax.jms.JMSException jmse) {
        jmse.printStackTrace();
      }
    } catch (java.lang.RuntimeException rte) {
      rte.printStackTrace();
    }
  }
 /**
  * This standard implementation searches the tree for objects of the correct type with a name
  * attribute matching the identifier.
  */
 protected void resolve(
     String identifier,
     ContainerType container,
     org.eclipse.emf.ecore.EReference reference,
     int position,
     boolean resolveFuzzy,
     ssl.resource.ssl.ISslReferenceResolveResult<ReferenceType> result) {
   try {
     org.eclipse.emf.ecore.EClass type = reference.getEReferenceType();
     org.eclipse.emf.ecore.EObject root =
         ssl.resource.ssl.util.SslEObjectUtil.findRootContainer(container);
     // first check whether the root element matches
     boolean continueSearch = checkElement(root, type, identifier, resolveFuzzy, true, result);
     if (!continueSearch) {
       return;
     }
     // then check the contents
     for (java.util.Iterator<org.eclipse.emf.ecore.EObject> iterator = root.eAllContents();
         iterator.hasNext(); ) {
       org.eclipse.emf.ecore.EObject element = iterator.next();
       continueSearch = checkElement(element, type, identifier, resolveFuzzy, true, result);
       if (!continueSearch) {
         return;
       }
     }
     org.eclipse.emf.ecore.resource.Resource resource = container.eResource();
     if (resource != null) {
       org.eclipse.emf.common.util.URI uri = getURI(identifier, resource.getURI());
       if (uri != null) {
         org.eclipse.emf.ecore.EObject element =
             loadResource(container.eResource().getResourceSet(), uri);
         if (element == null) {
           return;
         }
         checkElement(element, type, identifier, resolveFuzzy, false, result);
       }
     }
   } catch (java.lang.RuntimeException rte) {
     // catch exception here to prevent EMF proxy resolution from swallowing it
     rte.printStackTrace();
   }
 }
  private PluginResult internalRegister(JSONArray data, String callbackId) {
    JSONObject params = null;
    try {
      params = data.getJSONObject(0);
    } catch (JSONException e) {
      e.printStackTrace();
      return new PluginResult(Status.ERROR);
    }

    try {
      mPushManager =
          new PushManager(
              cordova.getActivity(), params.getString("appid"), params.getString("projectid"));
    } catch (JSONException e) {
      e.printStackTrace();
      return new PluginResult(Status.ERROR);
    }

    try {
      if (loggedStart) {
        mPushManager.onStartup(cordova.getActivity(), false);
      } else {
        mPushManager.onStartup(cordova.getActivity(), true);
        loggedStart = true;
      }
    } catch (java.lang.RuntimeException e) {
      e.printStackTrace();
      return new PluginResult(Status.ERROR);
    }

    checkMessage(cordova.getActivity().getIntent());

    callbackIds.put("registerDevice", callbackId);

    PluginResult result = new PluginResult(Status.NO_RESULT);
    result.setKeepCallback(true);
    return result;
  }