Example usage for android.app Activity getClass

List of usage examples for android.app Activity getClass

Introduction

In this page you can find the example usage for android.app Activity getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.dalaran.annotation.validator.Validator.java

public boolean validate(Activity a) {
    Field[] declaredFields = a.getClass().getDeclaredFields();
    boolean valid = false;
    for (Field field : declaredFields) {
        Annotation[] annotations = field.getAnnotations();
        for (Annotation annotation : annotations) {
            if (annotation.annotationType().equals(Length.class)) {
                boolean b = checkToValidate(a, field, (Length) annotation);
                if (b) {
                    valid = b;//from   w w w  .  j  av a2s  .c  o m
                }
            }
            if (annotation.annotationType().equals(Email.class)) {
                boolean b = checkToValidateEmail(a, field, (Email) annotation);
                if (b) {
                    valid = b;
                }
            }
            if (annotation.annotationType().equals(EqualsWith.class)) {
                boolean b = checkToValidateEquals(a, field, (EqualsWith) annotation);
                if (b) {
                    valid = b;
                }
            }
        }
    }
    return valid;
}

From source file:br.com.hotforms.FacebookHash.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *///  w w w .j a  v a 2s  .  c  o m
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    if ("getHash".equals(action)) {
        try {
            String packageName = activity.getClass().getPackage().getName();
            PackageManager packageManager = activity.getPackageManager();
            PackageInfo info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String hash = Base64.encodeToString(md.digest(), Base64.DEFAULT);

                String result = String.format("{ FacebookHash : \"%s\", PackageName : \"%s\"}", hash.trim(),
                        packageName);
                callbackContext.success(result);
            }
        } catch (NameNotFoundException e) {
            callbackContext.error(e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            callbackContext.error(e.getMessage());
        }
        return true;
    }

    return false;
}

From source file:com.example.basedemo.view.ViewInjectorImpl.java

@Override
public void inject(Activity activity) {
    //?ActivityContentView
    Class<?> handlerType = activity.getClass();
    try {/*w  w w.j a v  a2s.c  om*/
        ContentView contentView = findContentView(handlerType);
        if (contentView != null) {
            int viewId = contentView.value();
            if (viewId > 0) {
                Method setContentViewMethod = handlerType.getMethod("setContentView", int.class);
                setContentViewMethod.invoke(activity, viewId);
            }
        }
    } catch (Throwable ex) {
        Log.e(ex.getMessage(), ex.toString());
    }

    injectObject(activity, handlerType, new ViewFinder(activity));
}

From source file:com.asuka.android.asukaandroid.view.ViewInjectorImpl.java

@Override
public void inject(Activity activity) {
    //?ActivityContentView
    Class<?> handlerType = activity.getClass();
    try {/*from  ww  w  .j a v  a  2  s .  co m*/
        ContentView contentView = findContentView(handlerType);
        if (contentView != null) {
            int viewId = contentView.value();
            if (viewId > 0) {
                Method setContentViewMethod = handlerType.getMethod("setContentView", int.class);
                setContentViewMethod.invoke(activity, viewId);
            }
        }
    } catch (Throwable ex) {
        LogUtil.e(ex.getMessage(), ex);
    }

    injectObject(activity, handlerType, new ViewFinder(activity));
}

From source file:org.dmfs.android.retentionmagic.RetentionMagic.java

public static void init(final Activity activity, final Bundle extras) {
    try {/* w w  w.  ja v a2s .  c o  m*/
        init(activity.getClass(), activity, extras);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.vuze.android.remote.VuzeEasyTrackerOld.java

/**
 * @param arg0//  ww  w .  ja va 2s  . c o  m
 * @see com.google.analytics.tracking.android.EasyTracker#activityStart(android.app.Activity)
 */
public void activityStart(Activity activity) {

    easyTracker.set(Fields.SCREEN_NAME, activity.getClass().getSimpleName());
    MapBuilder mapBuilder = MapBuilder.createAppView().set(Fields.SCREEN_NAME,
            activity.getClass().getSimpleName());
    Intent intent = activity.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            mapBuilder.setAll(getReferrerMapFromUri(data));
        }
    }
    easyTracker.send(mapBuilder.build());
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    Log.d(getTag(), "Activity " + activity.getClass().getName() + ", "
            + (activity instanceof OnScheduleSelectedListener));
    // If the container activity has implemented
    // the callback interface, set it as listener
    if (activity instanceof OnScheduleSelectedListener) {
        mScheduleSelectedCallback = (OnScheduleSelectedListener) activity;
    }//from  ww  w.jav a2s . c  om
}

From source file:es.usc.citius.servando.calendula.fragments.RoutinesListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    Log.d(getTag(), "Activity " + activity.getClass().getName() + ", "
            + (activity instanceof OnRoutineSelectedListener));
    // If the container activity has implemented
    // the callback interface, set it as listener
    if (activity instanceof OnRoutineSelectedListener) {
        mRoutineSelectedCallback = (OnRoutineSelectedListener) activity;
    }/*from  w  ww.ja v  a 2 s  .  c  o m*/
}

From source file:org.dmfs.android.retentionmagic.RetentionMagic.java

public static void init(final Activity activity, final SharedPreferences prefs) {
    try {//from w  w w. j av  a 2s.c om
        init(activity.getClass(), activity, prefs);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.secupwn.aimsicd.AndroidIMSICatcherDetector.java

public void addTask(Activity activity, BaseAsyncTask<?, ?, ?> pTask) {
    if (activity == null) {
        return;/*from w w  w  . ja v a2  s  .c o m*/
    }

    log.debug("BaseTask addTask activity:" + activity.getClass().getCanonicalName());

    int key = activity.getClass().getCanonicalName().hashCode();
    List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(key);
    if (tasks == null) {
        tasks = new ArrayList<>();
        mActivityTaskMap.put(key, tasks);
    }
    log.verbose("BaseTask added:" + pTask.toString());
    tasks.add(pTask);
}