Example usage for android.app Activity finish

List of usage examples for android.app Activity finish

Introduction

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

Prototype

public void finish() 

Source Link

Document

Call this when your activity is done and should be closed.

Usage

From source file:com.sythealth.fitness.util.Utils.java

/**
 * /*from   w w w .  j a va 2  s  .  c o  m*/
 * @param activity ?context
 * @param cls activity
 * @param b ?
 * @param b1 ???activity
 */
public static void jumpUI(final Activity activity, final Class<?> cls, final boolean b, final boolean b1) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);
    activity.startActivity(intent);
    if (b) {
        activity.overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
    }
    if (b1) {
        activity.finish();
    }
}

From source file:Main.java

/**
 * Show dialog and give 2 options: go to settings or leave the app
 *
 * @param activity the activity/*from  ww  w  .  ja va 2 s  .co m*/
 */
private static void showDialog(final Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setTitle("Bluetooth is turned off");
    builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON");
    builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
            activity.startActivity(setnfc);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            activity.finish();
        }
    });
    builder.show();
}

From source file:com.hemou.android.account.AccountUtils.java

/**
 * Show conflict message about previously registered authenticator from
 * another application// w  ww.  ja va 2s  .c  o  m
 * 
 * @param activity
 */
private static void showConflictMessage(final Activity activity) {
    AlertDialog dialog = LightAlertDialog.create(activity);
    dialog.setTitle(activity.getString(string.authenticator_conflict_title));
    dialog.setMessage(activity.getString(string.authenticator_conflict_message));
    dialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            activity.finish();
        }
    });
    dialog.setButton(BUTTON_POSITIVE, activity.getString(android.R.string.ok), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            activity.finish();
        }
    });
    dialog.show();
}

From source file:im.vector.activity.CommonActivityUtils.java

public static void disconnect(Activity activity) {
    stopEventStream(activity);/*from ww w  . j av a  2  s  .c o m*/
    activity.finish();
    Matrix.getInstance(activity).mHasBeenDisconnected = true;
}

From source file:com.android.settings.util.Helpers2.java

/**
 * Restart the activity smoothly//  w  w  w.ja  v a 2s  . c o m
 *
 * @param activity
 */
public static void restartPC(final Activity activity) {
    if (activity == null)
        return;
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:com.github.javiersantos.piracychecker.LibraryUtils.java

static AlertDialog buildUnlicensedDialog(Context context, String title, String content) {
    if (!(context instanceof Activity))
        return null;
    final Activity activity = (Activity) context;
    return new AlertDialog.Builder(context).setCancelable(false).setTitle(title).setMessage(content)
            .setPositiveButton(context.getString(R.string.app_unlicensed_close),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (activity.isFinishing())
                                return;
                            activity.finish();
                        }/*from   ww w . j a  v  a  2  s .  co m*/
                    })
            .create();
}

From source file:jp.sonymusicstudio.cast.castcompanionlibrary.utils.Utils.java

/**
 * A utility method to validate that the appropriate version of the Google Play Services is
 * available on the device. If not, it will open a dialog to address the issue. The dialog
 * displays a localized message about the error and upon user confirmation (by tapping on
 * dialog) will direct them to the Play Store if Google Play services is out of date or
 * missing, or to system settings if Google Play services is disabled on the device.
 *//*from  w  w  w . ja va2  s.co m*/
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
    switch (googlePlayServicesCheck) {
    case ConnectionResult.SUCCESS:
        return true;
    default:
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                activity.finish();
            }
        });
        dialog.show();
    }
    return false;
}

From source file:dentex.youtube.downloader.utils.Utils.java

public static void reload(Activity activity) {
    //finish/*from w  w w  .  j a v a  2 s  .  c o m*/
    activity.finish();
    activity.overridePendingTransition(0, 0);

    //start
    Intent intent = activity.getIntent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    activity.startActivity(intent);
    activity.overridePendingTransition(0, 0);
}

From source file:com.felkertech.n.ActivityUtils.java

public static void openIntroIfNeeded(Activity activity) {
    SettingsManager sm = new SettingsManager(activity);
    if (sm.getInt(R.string.sm_last_version) < LAST_GOOD_BUILD) {
        activity.startActivity(new Intent(activity, Intro.class));
        activity.finish();
    }//from w w  w .  j  a  va 2  s.  c  o m
}

From source file:com.frostwire.android.gui.util.UIUtils.java

public static void goToFrostWireMainActivity(Activity activity) {
    final Intent intent = new Intent(activity, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    activity.startActivity(intent);/*from  w  w  w  .ja  v a2  s.c  o  m*/
    activity.finish();
    activity.overridePendingTransition(0, 0);
}