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:in.rab.ordboken.Ordboken.java

public boolean onOptionsItemSelected(Activity activity, MenuItem item) {
    if (item.getItemId() == R.id.menu_logout) {
        updateCreds("", "");
        mNeClient.logout();//  w ww.  jav  a 2  s  .c  o  m

        SharedPreferences.Editor ed = mPrefs.edit();
        ed.putBoolean("loggedIn", false);
        ed.putString("username", "");
        ed.putString("password", "");
        ed.commit();

        Intent intent = new Intent(mContext, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(intent);

        activity.finish();

        return true;
    } else if (item.getItemId() == android.R.id.home) {
        Intent upIntent = NavUtils.getParentActivityIntent(activity);
        if (NavUtils.shouldUpRecreateTask(activity, upIntent)) {
            TaskStackBuilder.create(activity).addNextIntentWithParentStack(upIntent).startActivities();
        } else {
            NavUtils.navigateUpFromSameTask(activity);
        }
        return true;
    }

    return false;
}

From source file:com.imgtec.hobbyist.fragments.loginsignup.LogInFragment.java

private void flowInitialization(final Activity activity) {
    BackgroundExecutor.execute(new ExternalRun() {
        @Override//w  w  w.j  av  a2 s  . c o m
        public void execute() {
            try {
                flowHelper.initFlowIfNotInitialized(activity);
            } catch (FlowException e) {
                DebugLogger.log(getClass().getSimpleName(), e);
                ActivitiesAndFragmentsHelper.showToast(appContext,
                        ErrorHtmlLogger.log(FlowEntities.getInstance(appContext).getLastError()), handler);
                activity.finish();
            }
        }
    });
}

From source file:com.example.haber.ui.activity.TabbedActivity.java

@Override
public void onBackPressed() {
    if (drawer.isDrawerVisible(navigationView)) {
        drawer.closeDrawers();//  w ww  .  j  a  v  a2 s.c o m
    } else {
        if (isQuit) {
            super.onBackPressed();
            for (Activity activity : MyApplication.instance.listActivity) {
                activity.finish();
            }
            HaberManagerUtil.releaseResource();
        } else {
            isQuit = true;
            Tools.showInfo(this, "?");
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    isQuit = false;
                }
            }, 3000);
        }

    }

}

From source file:com.numenta.taurus.chart.AbstractAnomalyChartFragment.java

public void goBack() {
    final Activity activity = getActivity();
    if (activity != null && !activity.isTaskRoot()) {
        final Intent data = new Intent();
        if (_chartData != null) {
            data.putExtra(EXTRA_TYPE, _chartData.getType());
            data.putExtra(EXTRA_ID, _chartData.getId());
            data.putExtra(EXTRA_AGGREGATION, _chartData.getAggregation());
        }//w  w w .j  a v  a 2s  . co m

        activity.setResult(Activity.RESULT_OK, data);
        // Go Back
        activity.finish();
    }
}

From source file:it.evilsocket.dsploit.core.System.java

public static boolean checkNetworking(final Activity current) {
    if (Network.isWifiConnected(mContext) == false) {
        AlertDialog.Builder builder = new AlertDialog.Builder(current);

        builder.setCancelable(false);/*w w  w . j a va2 s.  co  m*/
        builder.setTitle("Error");
        builder.setMessage("WiFi connectivity went down.");
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();

                Bundle bundle = new Bundle();
                bundle.putBoolean(WifiScannerActivity.CONNECTED, false);

                Intent intent = new Intent();
                intent.putExtras(bundle);

                current.setResult(Activity.RESULT_OK, intent);

                current.finish();
            }
        });

        AlertDialog alert = builder.create();
        alert.show();

        return false;
    }

    return true;
}

From source file:de.persoapp.android.core.adapter.MainViewFragment.java

protected void finish() {
    Activity activity = getActivity();
    if (activity == null) {
        return;//  w  w  w  .  j  ava 2 s. c om
    }

    excludeFromRecentAppList(activity);

    if (isAuthenticationSuccess()) {
        if (mRefreshBrowser) {
            sendIntentToBrowser();
        } else {
            activity.setResult(Activity.RESULT_OK,
                    new Intent().putExtra(EXTRA_REFRESH_ADDRESS, mRefreshAddress));
        }
    }

    activity.finish();
}

From source file:org.kontalk.ui.GroupInfoFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // action mode is active - no processing
    if (isActionModeActive())
        return true;

    switch (item.getItemId()) {
    case R.id.menu_invite:
        Activity parent = getActivity();
        if (parent != null) {
            parent.setResult(GroupInfoActivity.RESULT_ADD_USERS, null);
            parent.finish();
        }//from  w w  w . j a  v a  2s  .  c om
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:org.sufficientlysecure.keychain.ui.EditKeyFragment.java

@Override
public void onQueuedOperationSuccess(OperationResult result) {

    // null-protected from Queueing*Fragment
    Activity activity = getActivity();

    // if good -> finish, return result to showkey and display there!
    Intent intent = new Intent();
    intent.putExtra(OperationResult.EXTRA_RESULT, result);
    activity.setResult(Activity.RESULT_OK, intent);
    activity.finish();

}

From source file:com.robopupu.component.AppManagerImpl.java

@Override
public void exitApplication() {
    final Activity activity = featureManager.getForegroundActivity();
    final AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(R.string.ft_main_dialog_title_exit_confirmation);
    alertDialog.setMessage(getString(R.string.ft_main_dialog_prompt_exit_app));
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.action_ok),
            new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.dismiss();//from w ww .  j a v a2s  .co  m
                    exitObserver.onAppExit();
                    activity.finish();
                }
            });
    alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.action_cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                    // Just dismiss the dialog
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}