List of usage examples for android.app Activity getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static void recreate(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { activity.recreate();//w w w . j av a 2 s . co m } else { Intent intent = activity.getIntent(); intent.setClass(activity, activity.getClass()); activity.startActivity(intent); activity.finish(); activity.overridePendingTransition(0, 0); } }
From source file:com.sun.inject.Injector.java
/** * Injects all fields that are marked with the {@link InjectView} annotation. * <p>/*from w ww . ja v a 2 s. c o m*/ * For each field marked with the InjectView annotation, a call to {@link Activity#findViewById(int)} will be made, passing in the resource id stored in the * value() method of the InjectView annotation as the int parameter, and the result of this call will be assigned to the field. * * @throws IllegalStateException * if injection fails, common causes being that you have used an invalid id value, or you haven't called setContentView() on your Activity. */ public static final void injectActivity(Activity activity) { if (activity == null) return; Field[] fields = activity.getClass().getDeclaredFields(); if (fields == null || fields.length == 0) return; try { for (Field field : fields) { if (field.isAnnotationPresent(InjectView.class)) { injectViewByActivity(field, activity); } else if (field.isAnnotationPresent(InjectFragment.class)) { injectFragmentByActivity(field, activity); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:cn.bingoogolapple.scaffolding.util.UMAnalyticsUtil.java
/** * ActivityLifecycleCallbacks onActivityResumed * * @param activity//from ww w . j ava2s . c om */ public static void onActivityResumed(Activity activity) { if (sIsInit) { // ? if (AppManager.getInstance().isActivityNotContainFragment(activity)) { MobclickAgent.onPageStart(activity.getClass().getSimpleName()); } // MobclickAgent.onResume(activity); } }
From source file:Main.java
public static void displayErrorDialog(Activity activity, Exception e) { String message = e.getLocalizedMessage(); if (message == null || message == "") { message = e.getClass().getName(); } else {/* w w w. j ava 2s . c o m*/ message = e.getClass().getName() + ": " + message; } Log.e(activity.getClass().toString(), "Exception: " + message, e); final String title = "Error"; displayInfoBox(activity, title, message); }
From source file:org.andstatus.app.util.Permissions.java
/** * See http://stackoverflow.com/questions/30719047/android-m-check-runtime-permission-how-to-determine-if-the-user-checked-nev *//*from w w w . j a v a 2 s . c o m*/ public static void checkPermissionAndRequestIt(@NonNull Activity activity, @NonNull PermissionType permissionType) { if (checkPermission(activity, permissionType)) { return; } if (!ActivityCompat.OnRequestPermissionsResultCallback.class.isAssignableFrom(activity.getClass())) { throw new IllegalArgumentException("The activity " + activity.getClass().getName() + " should implement OnRequestPermissionsResultCallback"); } MyLog.d(activity, "Requesting permission: " + permissionType); ActivityCompat.requestPermissions(activity, new String[] { permissionType.manifestPermission }, permissionType.ordinal()); }
From source file:com.ccs.wedate.common.eventbus.util.ErrorDialogManager.java
private static boolean isSupportActivity(Activity activity) { boolean isSupport = false; for (Class<?> c = activity.getClass().getSuperclass();; c = c.getSuperclass()) { if (c == null) { throw new RuntimeException("Illegal activity type: " + activity.getClass()); }/*from w w w.ja v a2s. c o m*/ String name = c.getName(); if (name.equals("android.support.v4.app.FragmentActivity")) { isSupport = true; break; } else if (name.startsWith("com.actionbarsherlock.app") && (name.endsWith(".SherlockActivity") || name.endsWith(".SherlockListActivity") || name.endsWith(".SherlockPreferenceActivity"))) { throw new RuntimeException("Please use SherlockFragmentActivity. Illegal activity: " + name); } else if (name.equals("android.app.Activity")) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { throw new RuntimeException( "Illegal activity without fragment support. Either use Android 3.0+ or android.support.v4.app.FragmentActivity."); } break; } } return isSupport; }
From source file:com.binomed.showtime.android.util.CineShowTimeLayoutUtils.java
/** * Set the theme of the Activity, and restart it by creating a new Activity of the same type. *///from w w w . ja va2s. c om public static void changeToTheme(Activity activity, Intent originalIntent) { activity.finish(); Intent newIntent = new Intent(activity, activity.getClass()); newIntent.replaceExtras(originalIntent); activity.startActivity(newIntent); }
From source file:com.ccs.wedate.common.eventbus.util.ErrorDialogManager.java
/** Scope is limited to the activity's class. */ public static void attachTo(Activity activity, boolean finishAfterDialog, Bundle argumentsForErrorDialog) { Object executionScope = activity.getClass(); attachTo(activity, executionScope, finishAfterDialog, argumentsForErrorDialog); }
From source file:com.dimasdanz.kendalipintu.NFCOpenDoorActivity.java
public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);/* w ww.j ava2s . c o m*/ IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][] {}; filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType(MIME_TEXT_PLAIN); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Check your mime type."); } adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); }
From source file:com.joulespersecond.oba.ObaAnalytics.java
/** * For reporting activities on Start//from w ww . j a v a2 s . c om * * @param activity The activity being reported */ public static void reportActivityStart(Activity activity) { if (isAnalyticsActive()) { Tracker tracker = Application.get().getTracker(Application.TrackerName.APP_TRACKER); tracker.setScreenName(activity.getClass().getSimpleName()); tracker.send(new HitBuilders.ScreenViewBuilder().build()); Tracker tracker2 = Application.get().getTracker(Application.TrackerName.GLOBAL_TRACKER); tracker2.setScreenName(activity.getClass().getSimpleName()); tracker2.send(new HitBuilders.ScreenViewBuilder().build()); } }