List of usage examples for android.app Activity isFinishing
public boolean isFinishing()
From source file:Main.java
public static boolean isAlive(Activity activity) { return activity != null && !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) && !activity.isFinishing(); }
From source file:org.solovyev.android.Threads.java
/** * Method tries to run <var>runnable</var> on UI thread. Run can be failed if: * 1. Specified <var>activity</var> is null * 2. Specified <var>activity</var> is finishing * * @param activity activity bound to runnable * @param runnable runnable to bve executed *//*from w ww .j a va 2s . co m*/ public static void tryRunOnUiThread(@Nullable final Activity activity, @Nonnull final Runnable runnable) { if (activity != null && !activity.isFinishing()) { if (isUiThread()) { runnable.run(); } else { activity.runOnUiThread(new Runnable() { @Override public void run() { // some time may pass and activity might be closing if (!activity.isFinishing()) { runnable.run(); } } }); } } }
From source file:com.xiaodu.permission.util2.ESPermission.java
private static Activity getActivity(Activity activity) { if (activity.isFinishing()) { return null; }/*from www . j av a2s . c om*/ return activity; }
From source file:Main.java
@SuppressLint("NewApi") public static boolean isActivityValid(@Nullable final Activity activity) { if (activity == null) { return false; } else {/*w ww. j a va 2s.c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return !activity.isFinishing() && !activity.isDestroyed(); } else { return !activity.isFinishing(); } } }
From source file:com.github.yuqilin.qmediaplayerapp.util.Permissions.java
public static void showSettingsPermissionDialog(final Activity activity, int mode) { if (activity.isFinishing() || (sAlertDialog != null && sAlertDialog.isShowing())) return;// ww w.j a v a2 s . c om sAlertDialog = createSettingsDialogCompat(activity, mode); }
From source file:piuk.blockchain.android.ui.dialogs.WelcomeDialog.java
public static void show(final FragmentManager fm, Activity activity, WalletApplication application) { try {//from w w w .j a v a 2 s .c o m if (activity.isFinishing()) return; hide(); NewAccountDialog.hide(); final DialogFragment prev = (DialogFragment) fm.findFragmentById(R.layout.welcome_dialog); final FragmentTransaction ft = fm.beginTransaction(); if (prev != null) { prev.dismiss(); ft.remove(prev); } ft.addToBackStack(null); final DialogFragment newFragment = instance(); if (activity.isFinishing()) return; newFragment.show(ft, FRAGMENT_TAG); if (application.getRemoteWallet() == null) { newFragment.setCancelable(false); } else { newFragment.setCancelable(application.decryptionErrors == 0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:io.github.mkjung.ivi.util.Permissions.java
public static void showStoragePermissionDialog(final Activity activity, boolean exit) { if (activity.isFinishing() || (sAlertDialog != null && sAlertDialog.isShowing())) return;/*w ww. j a v a 2 s . c o m*/ if (activity instanceof AppCompatActivity) sAlertDialog = createDialogCompat(activity, exit); else sAlertDialog = createDialog(activity, exit); }
From source file:Main.java
public static void finishAllActivies(Activity activity) { try {/* w w w. j av a 2 s . com*/ Class<?> clazz_Activity = Class.forName("android.app.Activity"); Field field_mMainThread = clazz_Activity.getDeclaredField("mMainThread"); field_mMainThread.setAccessible(true); Object mMainThread = field_mMainThread.get(activity); Class<?> clazz_ActivityThread = Class.forName("android.app.ActivityThread"); Field field_mActivities = clazz_ActivityThread.getDeclaredField("mActivities"); field_mActivities.setAccessible(true); Object mActivities = field_mActivities.get(mMainThread); HashMap<?, ?> map = (HashMap<?, ?>) mActivities; Collection<?> collections = map.values(); if (null != collections && !collections.isEmpty()) { Class<?> clazz_ActivityClientRecord = Class .forName("android.app.ActivityThread$ActivityClientRecord"); Field field_activitiy = clazz_ActivityClientRecord.getDeclaredField("activity"); field_activitiy.setAccessible(true); Activity acti; for (Object obj : collections) { acti = (Activity) field_activitiy.get(obj); Log.d(TAG, "activity.name=" + acti.getClass().getName()); if (null != acti && !acti.isFinishing()) { Log.d(TAG, "activity.name=" + acti.getClass().getName() + " not finish."); acti.finish(); } } } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:ru.strider.simplerecognizer.util.AdMob.java
@SuppressWarnings("deprecation") @SuppressLint("InlinedApi") public static void addAdView(Activity activity) { if (!activity.isFinishing()) { LinearLayout linearLayout = (LinearLayout) activity.findViewById(R.id.linearLayoutAdView); if (linearLayout != null) { AdView adView = (AdView) linearLayout.findViewById(R.id.adView); if (adView == null) { adView = new AdView(activity, AdSize.SMART_BANNER, PUBLISHER_ID); adView.setId(R.id.adView); linearLayout.addView(adView, (new LinearLayout.LayoutParams( ((Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) ? LinearLayout.LayoutParams.FILL_PARENT : LinearLayout.LayoutParams.MATCH_PARENT), LinearLayout.LayoutParams.WRAP_CONTENT))); }/* www . j a v a 2s .c om*/ adView.loadAd(getAdRequest()); } } }
From source file:com.dabay6.libraries.androidshared.ui.dialogs.changelog.util.ChangeLogDialogUtils.java
/** * Displays the applications change log. * * @param context {@link Context} used to create the change log dialog. * @param assetName Name of the asset file containing the change log json. * @param style The css style to be applied to the html. * @param callback The callback to call upon dismissal of the change log alert dialog. *//*from w w w . j a v a 2 s . c o m*/ public static void displayChangeLog(final Activity context, final String assetName, final String style, final OnChangeLogDialogListener callback) { if (context.isFinishing()) { return; } ChangeLogDialogUtils.createDialog(context, assetName, style, callback).show(); }