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;
  }
  public FREObject call(FREContext context, FREObject[] args) {
    Log.i(TAG, "InitFunction()");
    //		ExtensionActivity.extensionContext = context;

    Log.i(
        TAG,
        "ExtensionActivity.getInstance().extensionContext: "
            + ExtensionActivity.getInstance().extensionContext);
    Context appContext = context.getActivity().getApplicationContext();
    ExtensionActivity.getInstance().appContext = appContext;

    ExtensionActivity.getInstance().activityClassName = context.getActivity().getClass().getName();
    ExtensionActivity.notifyAppReady();
    return null;
  }
示例#3
0
  @Override
  public FREObject call(FREContext arg0, FREObject[] arg1) {

    Activity a = arg0.getActivity();
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(a);

    try {
      if (adapter == null) {
        return FREObject.newObject(false);
      }
    } catch (Exception e) {
    }
    NfcNdefManager.getInstance().adapter = NfcAdapter.getDefaultAdapter(a);
    NfcNdefManager.getInstance().pIntent =
        PendingIntent.getActivity(
            a, 0, new Intent(a, a.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    IntentFilter ndefFilter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
      ndefFilter.addDataType("text/plain");
    } catch (MalformedMimeTypeException mmte) {
    }
    NfcNdefManager.getInstance().ndefFilters = new IntentFilter[] {ndefFilter};

    IntentFilter tagFilter = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
    NfcNdefManager.getInstance().tagFilters = new IntentFilter[] {tagFilter};

    try {
      return FREObject.newObject(true);
    } catch (Exception e) {
    }
    return null;
  }
  public FREObject call(FREContext context, FREObject[] args) {
    if (args.length > 0) {
      // Retrieve the location
      String location = null;
      try {
        location = args[0].getAsString();
      } catch (Exception exception) {
        Log.d(TAG, exception.getLocalizedMessage());
        return null;
      }

      ChartBoost.getSharedChartBoost(context.getActivity()).cacheInterstitial(location);
    } else {
      ChartBoost.getSharedChartBoost(context.getActivity()).cacheInterstitial();
    }

    return null;
  }
  public FREObject call(FREContext context, FREObject[] args) {
    if (Build.MANUFACTURER.equals("Amazon")) {
      Log.d(TAG, "push notifications disabled on amazon devices, ignoring unregister");
      return null;
    }

    PushWoosh.getInstance().PushWooshNotificationUnRegister(context.getActivity());
    return null;
  }
  public FREObject call(FREContext context, FREObject[] args) {
    GameRequestContent.Builder builder = new GameRequestContent.Builder();
    FacebookObjectsConversionUtil.parseGameRequestContent(args[0], builder);
    GameRequestContent content = builder.build();
    String callback = FREConversionUtil.toString(args[1]);

    AirFacebookExtension.log(
        "GameRequestDialogFunction content:"
            + FacebookObjectsConversionUtil.toString(content)
            + " callback:"
            + callback);

    // Start dialog activity
    Intent i = new Intent(context.getActivity().getApplicationContext(), GameRequestActivity.class);
    i.putExtra(GameRequestActivity.extraPrefix + ".callback", callback);
    i.putExtra(GameRequestActivity.extraPrefix + ".content", content);
    context.getActivity().startActivity(i);

    return null;
  }
 @Override
 public FREObject call(FREContext context, FREObject[] arg1) {
   // TODO 自動生成されたメソッド・スタブ
   try {
     Activity activity = context.getActivity();
     mAudio = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
     int rtn = mAudio.getRingerMode();
     return FREObject.newObject(rtn);
   } catch (FREWrongThreadException e) {
     e.printStackTrace();
   }
   return null;
 }
  public FREObject call(FREContext ctx, FREObject[] passedArgs) {
    String instanceId;
    FREObject responseObject = null;
    String response;

    try {
      instanceId = passedArgs[0].getAsString();

      Method method;
      PubNubWrapper instance = InstancesContainer.getInstance(instanceId);

      method = instance.getClass().getMethod(methodName());
      response = (String) method.invoke(instance);
      responseObject = FREObject.newObject(response);
    } catch (InvocationTargetException e) {
      e.printStackTrace();
      ctx.dispatchStatusEventAsync("ERROR", e.getCause().getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      ctx.dispatchStatusEventAsync("ERROR", e.getMessage());
    }

    return responseObject;
  }
  @Override
  public FREObject call(FREContext context, FREObject[] args) {
    Context appContext = context.getActivity().getApplicationContext();
    AudioManager aManager = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);

    double volume = 1;
    try {
      volume = args[0].getAsDouble();
    } catch (Exception e) {

    }

    int maxVolume = aManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    volume = volume * maxVolume;
    int index = (int) volume;

    aManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);

    return null;
  }
示例#10
0
  public FREObject call(FREContext ctx, FREObject[] passedArgs) {

    FREObject result = null;
    String BASE64_PUBLIC_KEY = null;
    Activity act;

    try {
      BASE64_PUBLIC_KEY = passedArgs[0].getAsString();
      act = ctx.getActivity();
      checkLicense(ctx, act, BASE64_PUBLIC_KEY);
      result = FREObject.newObject(1);

    } catch (FRETypeMismatchException e) {
      System.out.println("##### AndroidLicensing - caught FRETypeMismatchException");
      e.printStackTrace();
    } catch (FREInvalidObjectException e) {
      System.out.println("##### AndroidLicensing - caught FREInvalidObjectException");
      e.printStackTrace();
    } catch (FREWrongThreadException e) {
      System.out.println("##### AndroidLicensing - caught FREWrongThreadException");
      e.printStackTrace();
    }
    return result;
  }
示例#11
0
 /** 结果传给AS端 */
 public void callBack(String status) {
   Log.d(TAG, "-----status----" + status);
   _context.dispatchStatusEventAsync(TAG, "status:" + status);
 }
示例#12
0
  public static void handleException(FREContext context, Exception e) {
    if (DEBUG_ENABLED) e.printStackTrace();

    if (context != null) context.dispatchStatusEventAsync(ExtensionEvent.ERROR, e.getMessage());
  }