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.artemchep.horario.ui.widgets.SwipeBackLayout.java

private void finish() {
    if (finishListener != null) {
        finishListener.onFinish();/*from   w  w  w.  ja v a  2  s .co  m*/
    } else {
        Activity act = (Activity) getContext();
        act.finish();
        act.overridePendingTransition(0, android.R.anim.fade_out);
    }
}

From source file:com.example.android.honeypad.ui.NoteListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {/*w ww . j a  va  2  s  . c  o  m*/
        // check that the containing activity implements our callback
        mContainerCallback = (NoteEventsCallback) activity;
    } catch (ClassCastException e) {
        activity.finish();
        throw new ClassCastException(activity.toString() + " must implement NoteSelectedCallback");
    }
}

From source file:ru.valle.btc.MainActivityTest.java

public void testAlwaysGenerateNewAddress() {
    Activity activity = getActivity();
    String address = waitForAddress(activity);
    assertNotNull(address);/*from w w w  .  j ava 2s.c om*/
    activity.finish();
    setActivity(null);
    assertFalse(getActivity().isFinishing());
    activity = getActivity();
    String anotherAddress = waitForAddress(activity);
    assertNotNull(anotherAddress);
    assertNotSame(address, anotherAddress);
}

From source file:ir.isilearning.lmsapp.fragment.SignInFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    assurePlayerInit();/*from w w  w  . j  ava2  s  .c  o m*/
    checkIsInEditMode();

    if (mPlayer == null || edit) {
        view.findViewById(R.id.empty_progressbar).setVisibility(View.GONE);
        view.findViewById(R.id.content).setVisibility(View.VISIBLE);
        initContentViews(view);
        initContents();
    } else {
        final Activity activity = getActivity();
        CategorySelectionActivity.start(activity, mPlayer);
        activity.finish();
    }
    super.onViewCreated(view, savedInstanceState);
}

From source file:com.beem.project.beem.ui.wizard.CreateAccountFragment.java

/**
 * Callback called when the account is successfully created.
 *
 * @param jid the jid of the account./*  w ww.  j  av  a 2  s. c  om*/
 * @param pass the password of the account.
 *
 */
private void onAccountCreationSuccess(String jid, String pass) {
    Activity a = getActivity();
    saveCredential(jid, pass);
    // launch login
    Intent i = new Intent(a, Login.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
    a.finish();
}

From source file:cn.bingoogolapple.scaffolding.util.AppManager.java

/**
 * Activity//from  www.ja  v a2  s  .c  o  m
 *
 * @param activity
 */
public void popOneActivity(Activity activity) {
    if (activity == null || mActivityStack.isEmpty()) {
        return;
    }
    if (!activity.isFinishing()) {
        activity.finish();
    }
    mActivityStack.remove(activity);
}

From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java

public void onActionClicked(Activity activity, Action action) {
    if (activity instanceof ActionAdapter.Listener) {
        ((ActionAdapter.Listener) activity).onActionClicked(action);
    } else {/*  w  w w  .  j ava2  s  .  c om*/
        Intent intent = action.getIntent();
        if (intent != null) {
            activity.startActivity(intent);
            activity.finish();
        }
    }
}

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

/**
 * Get account used for authentication/*from w  w  w .  j  a va  2s  .co  m*/
 * 
 * @param manager
 * @param act
 * @return account
 * @throws IOException
 * @throws AccountsException
 */
public static Account getAccount(final AccountManager manager, final Activity act)
        throws IOException, AccountsException {
    final String SUB_TAG = "acnt_get";
    final boolean loggable = Log.isLoggable(SUB_TAG, DEBUG);
    if (loggable)
        Log.d(SUB_TAG, "Getting account");

    if (act == null)
        throw new IllegalArgumentException("Activity cannot be null");

    if (act.isFinishing()) {
        Log.v(SUB_TAG, act.getClass().getName()
                + "--->?finish()OperationCanceledException...");
        throw new OperationCanceledException();
    }

    Account[] accounts;
    try {
        if (!hasAuthenticator(manager)) {
            Log.e(SUB_TAG, "Current user is not under the authenticated environment....");
            throw new AuthenticatorConflictException();
        }

        while ((accounts = getAccounts(manager)).length == 0) {
            Bundle result = manager.addAccount(ACCOUNT_TYPE, AUTHTOKEN_TYPE, null, null, act, null, null)
                    .getResult();
        }
    } catch (OperationCanceledException e) {
        Log.d(SUB_TAG, "Excepting retrieving account", e);
        act.finish();
        throw e;
    } catch (AccountsException e) {
        Log.d(SUB_TAG, "Excepting retrieving account", e);
        throw e;
    } catch (AuthenticatorConflictException e) {
        act.runOnUiThread(new Runnable() {

            public void run() {
                showConflictMessage(act);
            }
        });
        throw e;
    } catch (IOException e) {
        Log.d(SUB_TAG, "Excepting retrieving account", e);
        throw e;
    }

    // if (loggable)
    Log.d(SUB_TAG, "Returning account " + accounts[0].name);

    return accounts[0];
}

From source file:com.diusrex.update.Update.java

public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException {
    Activity activity = this.cordova.getActivity();
    final String appPackageName = activity.getPackageName();
    try {/*ww  w .ja  va2s. co m*/
        activity.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
    } catch (android.content.ActivityNotFoundException anfe) {
        activity.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
    }

    boolean quitApp = args.getBoolean(0);
    if (quitApp) {
        activity.finish();
    }

    return true;
}

From source file:fr.cph.stock.android.StockTrackerApp.java

/**
 * This function loads the error activity to the screen. It happens usually when the session is timeout and needs to request a
 * new session id to the server/*w  ww .j a  va  2s .  co  m*/
 * 
 * @param currentActivity
 *            the activity to stop
 * @param jsonObject
 *            the json object containing the error message
 */
public void loadErrorActivity(Activity currentActivity, JSONObject jsonObject) {
    Intent intent = new Intent(this, ErrorActivity.class);
    intent.putExtra("data", jsonObject.toString());
    SharedPreferences settings = getSharedPreferences(BaseActivity.PREFS_NAME, 0);
    String login = settings.getString("login", null);
    String password = settings.getString("password", null);
    intent.putExtra("login", login);
    intent.putExtra("password", password);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    currentActivity.finish();
}