/**
   * Static function to send a SMS to JS.
   *
   * @param sms
   * @throws IOException
   */
  public static void sendMessage(final SmsMessage msg) throws IOException {
    Log.d(TAG, "sendMessage Called");
    // build JSON message
    JSONObject sms = new JSONObject();

    try {
      MultipleSmsHandler smsHand = new MultipleSmsHandler();
      sms.put("origin", msg.getOriginatingAddress());
      sms.put("body", msg.getMessageBody());
      // sms.put("id", msg.getTimestampMillis());

      // String smsSimulation = " Absa: SPR 9437, Gesk, 29/06/12 DIREKTE DEBIET,
      // DEAGOSTINI-4X000500, R-253.90, Saldo R4,093.75. Hulp 0860008600; VDWALPG043";
      try {
        if (smsHand.parseSMS(msg.getMessageBody() + ":" + msg.getTimestampMillis())) {

          // When the Activity is not loaded, the currentPluginInstance is null

          if (currentPluginInstance != null) {
            // build code to call function
            String code = "javascript:" + callbackFunction + "(" + sms.toString() + ");";

            // Log.v(TAG + ":sendJavascript", code);

            // execute code
            // currentPluginInstance.sendJavascript(code);
            currentPluginInstance.sendJavascript("javascript:notificationCallback()");
          } else {

          }
        }
        Log.d(TAG, "SUCCESS");
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      /*Date dateObj = new Date(msg.getTimestampMillis());
      DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
      String timeDate = df.format(dateObj);
      //Log.v(TAG + ":sendJavascript", timeDate);

      sms.put("time", timeDate);*/
    } catch (JSONException e) {
      Log.e(TAG + ":sendMessage", "JSON exception");
    }
  }
Ejemplo n.º 2
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
  }