Example usage for android.app Activity isFinishing

List of usage examples for android.app Activity isFinishing

Introduction

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

Prototype

public boolean isFinishing() 

Source Link

Document

Check to see whether this activity is in the process of finishing, either because you called #finish on it or someone else has requested that it finished.

Usage

From source file:Main.java

private static void post(@Nullable Activity target, @NonNull Runnable runnable) {
    if (target == null || target.isFinishing())
        return;//from   w w  w. j av a  2 s  .c  o  m
    target.runOnUiThread(runnable);
}

From source file:Main.java

public static boolean isActivityAvaliable(Activity activity) {
    if (activity == null)
        return false;
    if (activity.isFinishing())
        return false;
    return true;//ww w  .ja v  a2 s .  c o m
}

From source file:Main.java

private static void post(@Nullable Activity target, @NonNull Runnable runnable) {
    if (target == null || target.isFinishing()) {
        return;//from   w w  w.  j a  va 2s  . c o m
    }
    target.runOnUiThread(runnable);
}

From source file:Main.java

public static void showYesNoPrompt(Context _context, String title, String message,
        OnClickListener onYesListener, OnClickListener onNoListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(_context);
    builder.setTitle(title);//from w ww.  j a va 2 s. c  om
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setMessage(message);
    builder.setCancelable(false);
    builder.setPositiveButton("Yes", onYesListener);
    builder.setNegativeButton("No", onNoListener);
    boolean show = true;
    if (_context instanceof Activity) {
        Activity activity = (Activity) _context;
        if (activity.isFinishing()) {
            show = false;
        }
    }
    if (show)
        builder.show();
}

From source file:Main.java

public static void showMessage(Context _context, String title, String message, int icon,
        DialogInterface.OnClickListener ackHandler) {
    AlertDialog.Builder builder = new AlertDialog.Builder(_context);
    builder.setTitle(title);/*from   w ww  . j  a  va2 s. co m*/
    builder.setMessage(Html.fromHtml(message));
    builder.setCancelable(false);
    builder.setPositiveButton("Acknowledged", ackHandler);
    builder.setIcon(icon);
    boolean show = true;
    if (_context instanceof Activity) {
        Activity activity = (Activity) _context;
        if (activity.isFinishing()) {
            show = false;
        }
    }
    if (show)
        builder.show();
}

From source file:Main.java

/**
 * Sets up the NFC adapter to send a list of {@link Uri} with 'file' or 'content' scheme. To clear the NFC adapter
 * of the list of {@link Uri}, null should be passed as the second parameter.
 *
 * @param activity the {@link Activity}.
 * @param uris     the list of {@link Uri} to beam. Pass null to clear NFC adapter.
 *//*from ww  w . jav a  2  s .co m*/
public static void beamUris(Activity activity, Uri[] uris) {
    if (activity != null && !activity.isFinishing()) {
        NfcAdapter nfcAdapter = getNfcAdapter(activity);
        if (nfcAdapter != null) {
            try {
                nfcAdapter.setBeamPushUris(uris, activity);
            } catch (Exception e) {
                // Do nothing. An exception is thrown if a destroyed Activity is passed.
            }
        }
    }
}

From source file:Main.java

public static void showAlertDialog(final Activity activity, final String titel, final String text) {

    if (!activity.isFinishing()) {
        activity.runOnUiThread(new Runnable() {

            public void run() {
                aDialogBuilder = new AlertDialog.Builder(activity);
                aDialogBuilder.setMessage(text);
                aDialogBuilder.setTitle(titel);
                aDialogBuilder.setCancelable(false);
                aDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();

                    }/*from   w w  w  .jav  a2s.c  o m*/
                });
                aDialog = aDialogBuilder.create();
                aDialog.show();
            }
        });
    }

}

From source file:Main.java

public static boolean isActivityValid(Activity activity) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        return activity != null && !activity.isFinishing() && !activity.isChangingConfigurations();
    else/*from  w  w  w .  j  ava 2s.  c  o m*/
        return activity != null && !activity.isFinishing();
}

From source file:com.j1024.mcommon.support.Safeguard.java

private static boolean isValid(Activity activity) {
    if (activity == null)
        return false;

    return !activity.isFinishing();
}

From source file:Main.java

public static boolean isActivityValid(Activity activity) {
    if (activity == null) {
        return false;
    } else {// w  w  w .  j  a  v  a  2s  . c o  m
        if (Build.VERSION.SDK_INT >= 17) {
            return !activity.isFinishing() && !activity.isDestroyed();
        } else {
            return !activity.isFinishing();
        }
    }
}