public FREObject call(FREContext arg0, FREObject[] arg1) {
    // Retrieve permissions
    FREArray permissionsArray = (FREArray) arg1[0];

    long arrayLength = 0;
    try {
      arrayLength = permissionsArray.getLength();
    } catch (Exception e) {
      AirFacebookExtension.log("ERROR - " + e.getMessage());
    }

    String[] permissions = new String[(int) arrayLength];
    for (int i = 0; i < arrayLength; i++) {
      try {
        permissions[i] = permissionsArray.getObjectAt((long) i).getAsString();
      } catch (Exception e) {
        AirFacebookExtension.log("ERROR - " + e.getMessage());
        permissions[i] = null;
      }
    }

    // Start login activity
    Intent i = new Intent(arg0.getActivity().getApplicationContext(), LoginActivity.class);
    i.putExtra("permissions", permissions);
    arg0.getActivity().startActivity(i);

    return null;
  }
Example #2
0
  public static int[] GetObjectAsArrayOfNumbers(FREArray values) {
    try {
      int length = (int) values.getLength();
      int[] retArray = new int[length];

      for (int i = 0; i < length; i++) {
        FREObject value = values.getObjectAt(i);
        retArray[i] = value.getAsInt();
      }

      return retArray;
    } catch (Exception e) {
    }
    return new int[0];
  }
Example #3
0
  public static String[] GetObjectAsArrayOfStrings(FREArray values) {
    try {
      int length = (int) values.getLength();
      String[] retArray = new String[length];

      for (int i = 0; i < length; i++) {
        FREObject value = values.getObjectAt(i);
        retArray[i] = value.getAsString();
      }

      return retArray;
    } catch (Exception e) {
    }
    return new String[0];
  }
  @Override
  public FREObject call(FREContext arg0, FREObject[] arg1) {

    String eventName = null;

    try {
      eventName = arg1[0].getAsString();
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (FRETypeMismatchException e) {
      e.printStackTrace();
    } catch (FREInvalidObjectException e) {
      e.printStackTrace();
    } catch (FREWrongThreadException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }

    HashMap<String, String> params = new HashMap<String, String>();

    if (arg1[1] != null && arg1[2] != null) {
      FREArray paramsKeys = (FREArray) arg1[1];
      FREArray paramsValue = (FREArray) arg1[2];

      try {
        long paramsLength = paramsKeys.getLength();
        for (long i = 0; i < paramsLength; i++) {
          FREObject key = paramsKeys.getObjectAt(i);
          FREObject value = paramsValue.getObjectAt(i);
          String keyString = key.getAsString();
          String valueString = value.getAsString();
          Log.d(TAG, "[" + keyString + "] -> " + valueString);
          params.put(keyString, valueString);
        }

      } catch (FREInvalidObjectException e) {
        e.printStackTrace();
      } catch (FREWrongThreadException e) {
        e.printStackTrace();
      } catch (IllegalStateException e) {
        e.printStackTrace();
      } catch (FRETypeMismatchException e) {
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (arg1[1] != null) {
      Log.e(TAG, "parameterValues is null while parameterKeys is not");
    } else if (arg1[2] != null) {
      Log.e(TAG, "parameterKeys is null while parameterValues is not");
    }

    if (eventName != null) {
      if (params != null && params.size() > 0) {
        Log.d(TAG, "log event with params");
        FlurryAgent.logEvent(eventName, params);
        // FlurryAgent.onEvent(eventName, params);
      } else {
        Log.d(TAG, "log event without params");
        FlurryAgent.logEvent(eventName);
        // FlurryAgent.onEvent(eventName);
      }
    } else {
      Log.d(Extension.TAG, "null event name");
    }

    return null;
  }