List of usage examples for android.app Activity getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:io.atrac613.AbstractNfcTagFragment.java
@Override public void onResume() { Log.d(TAG, "*** AbstractNfcFeliCaTagFragment go Resume"); //foregrandDispathch Activity a = this.getActivity(); IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter tag = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); try {/* www . j a v a 2 s.c o m*/ ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } IntentFilter[] filters = new IntentFilter[] { ndef, tag, tech }; PendingIntent pendingIntent = PendingIntent.getActivity(a, 0, new Intent(a, a.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this.getActivity()); adapter.enableForegroundDispatch(this.getActivity(), pendingIntent, filters, registerTechList(mTechList)); super.onResume(); }
From source file:io.selendroid.server.ServerInstrumentation.java
public void resumeActivity() { Activity activity = activitiesReporter.getBackgroundActivity(); Log.d("TAG", "got background activity"); if (activity == null) { SelendroidLogger.error("activity class is empty", new NullPointerException("Activity class to start is null.")); return;//from w ww . ja v a 2 s.c o m } // start now the new activity Log.d("TAG", "background activity is not null"); Intent intent = new Intent(getTargetContext(), activity.getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); Log.d("TAG", "created intent and got target context"); getTargetContext().startActivity(intent); Log.d("TAG", "got target context and started activity"); activitiesReporter.setBackgroundActivity(null); }
From source file:fr.mixit.android.ui.fragments.MemberDetailsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!(activity instanceof MemberDetailsContract)) { throw new IllegalArgumentException( activity.getClass().getName() + " must implement MemberDetailsContract"); }/* www . j a v a 2s .c o m*/ }
From source file:com.smartnsoft.droid4me.app.ActivityController.java
/** * Indicates whether a redirection is required before letting the activity continue its life cycle. It launches the redirected {@link Activity} if a * redirection is need, and provide to its {@link Intent} the initial activity {@link Intent} trough the extra {@link Parcelable} * {@link ActivityController#CALLING_INTENT} key. * //from w w w . j av a 2 s .c o m * <p> * If the provided {@code activity} implements the {@link ActivityController.EscapeToRedirector} interface or exposes the * {@link ActivityController.EscapeToRedirectorAnnotation} annotation, the method returns {@code false}. * </p> * * <p> * Note that this method does not need to be marked as {@code synchronized}, because it is supposed to be invoked systematically from the UI thread. * </p> * * @param activity * the activity which is being proved against the {@link ActivityController.Redirector} * @return {@code true} if and only if the given activity should be paused (or ended) and if another activity should be launched instead through the * {@link Activity#startActivity(Intent)} method * @see ActivityController#extractCallingIntent(Activity) * @see ActivityController.Redirector#getRedirection(Activity) * @see ActivityController.EscapeToRedirector * @see ActivityController.EscapeToRedirectorAnnotation */ public boolean needsRedirection(Activity activity) { if (redirector == null) { return false; } if (activity instanceof ActivityController.EscapeToRedirector || activity.getClass() .getAnnotation(ActivityController.EscapeToRedirectorAnnotation.class) != null) { if (log.isDebugEnabled()) { log.debug("The Activity with class '" + activity.getClass().getName() + "' is escaped regarding the Redirector"); } return false; } final Intent intent = redirector.getRedirection(activity); if (intent == null) { return false; } if (log.isDebugEnabled()) { log.debug("A redirection is needed"); } // We redirect to the right Activity { // We consider the parent activity in case it is embedded (like in an ActivityGroup) final Intent formerIntent = activity.getParent() != null ? activity.getParent().getIntent() : activity.getIntent(); intent.putExtra(ActivityController.CALLING_INTENT, formerIntent); // Disables the fact that the new started activity should belong to the tasks history and from the recent tasks // intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); activity.startActivity(intent); } // We now finish the redirected Activity activity.finish(); return true; }
From source file:im.neon.activity.CommonActivityUtils.java
/** * Manage the trim memory./* w w w . j ava 2s .co m*/ * * @param activity the activity. * @param level the memory level */ public static void onTrimMemory(Activity activity, int level) { String activityName = (null != activity) ? activity.getClass().getSimpleName() : "NotAvailable"; Log.e(LOW_MEMORY_LOG_TAG, "Active application : onTrimMemory from " + activityName + " level=" + level); // TODO implement things to reduce memory usage displayMemoryInformation(activity, "onTrimMemory"); }
From source file:io.lqd.sdk.Liquid.java
private void attachActivity(Activity activity) { mAttachedActivities.put(activity.getClass().getName(), activity); if (LiquidOnEventListener.class.isInstance(activity)) { attachLiquidEventListener((LiquidOnEventListener) activity); }/*w ww. j a v a 2s .c om*/ }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void dataForPop(JSONObject data) { if (sActivitiesArrayList.size() >= 2) { boolean cobaltActivityFound = false; int index = sActivitiesArrayList.size() - 2; while (!cobaltActivityFound && index >= 0) { Activity activity = sActivitiesArrayList.get(index); if (CobaltActivity.class.isAssignableFrom(activity.getClass())) { ((CobaltActivity) activity).setDataNavigation(data); cobaltActivityFound = true; }//from w w w. j av a 2 s .c om index--; } if (!cobaltActivityFound && Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - dataForPop: CobaltActivity not found"); } }
From source file:io.lqd.sdk.Liquid.java
private void detachActivity(Activity activity) { mAttachedActivities.remove(activity.getClass().getName()); if (LiquidOnEventListener.class.isInstance(activity)) { detachLiquidEventListener((LiquidOnEventListener) activity); }/* w ww. j a v a 2s .c o m*/ }
From source file:im.neon.activity.CommonActivityUtils.java
/** * Manage the low memory case//from w w w .j a va2 s . c o m * * @param activity activity instance */ public static void onLowMemory(Activity activity) { if (!VectorApp.isAppInBackground()) { String activityName = (null != activity) ? activity.getClass().getSimpleName() : "NotAvailable"; Log.e(LOW_MEMORY_LOG_TAG, "Active application : onLowMemory from " + activityName); // it seems that onLowMemory is called whereas the device is seen on low memory condition // so, test if the both conditions if (displayMemoryInformation(activity, "onLowMemory test")) { if (CommonActivityUtils.shouldRestartApp(activity)) { Log.e(LOW_MEMORY_LOG_TAG, "restart"); CommonActivityUtils.restartApp(activity); } else { Log.e(LOW_MEMORY_LOG_TAG, "clear the application cache"); Matrix.getInstance(activity).reloadSessions(activity); } } else { Log.e(LOW_MEMORY_LOG_TAG, "Wait to be concerned"); } } else { Log.e(LOW_MEMORY_LOG_TAG, "background application : onLowMemory "); } displayMemoryInformation(activity, "onLowMemory global"); }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void popTo(String controller, String page, JSONObject data) { Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page); if (popToIntent != null) { Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras); String popToActivityClassName = popToExtras.getString(Cobalt.kActivity); try {//from w w w . ja va 2 s . c om Class<?> popToActivityClass = Class.forName(popToActivityClassName); boolean popToControllerFound = false; int popToControllerIndex = -1; for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) { Activity oldActivity = sActivitiesArrayList.get(i); Class<?> oldActivityClass = oldActivity.getClass(); Bundle oldBundle = oldActivity.getIntent().getExtras(); Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null; String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) { Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager() .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId()); if (fragment != null) { oldExtras = fragment.getArguments(); oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; } } if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class .isAssignableFrom(oldActivityClass) || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) { popToControllerFound = true; popToControllerIndex = i; ((CobaltActivity) oldActivity).setDataNavigation(data); break; } } if (popToControllerFound) { while (popToControllerIndex + 1 < sActivitiesArrayList.size()) { sActivitiesArrayList.get(popToControllerIndex + 1).finish(); } } else if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller + (page == null ? "" : " with page " + page) + " not found in history. Abort."); } catch (ClassNotFoundException exception) { exception.printStackTrace(); } } else if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller"); }