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.justplay1.shoppist.shared.base.activities.BaseActivity.java

public void finishActivity(Activity activity) {
    activity.finish();
    finishActivityAnimation(activity);
}

From source file:net.d53.syman.mobile.ui.ReferrerListFragment.java

public Loader<List<Referrer>> onCreateLoader(int id, Bundle args) {
    final List<Referrer> initialItems = items;
    return new ThrowableLoader<List<Referrer>>(getActivity(), items) {

        @Override//from  www. ja  va2  s  .  com
        public List<Referrer> loadData() throws Exception {
            try {
                return serviceProvider.getService().getReferrers(getArguments().getString(GAUGE_ID));
            } catch (OperationCanceledException e) {
                Activity activity = getActivity();
                if (activity != null)
                    activity.finish();
                return initialItems;
            }
        }
    };
}

From source file:net.d53.syman.mobile.ui.ContentListFragment.java

@Override
public Loader<List<PageContent>> onCreateLoader(int id, Bundle args) {
    final List<PageContent> initialItems = items;
    return new ThrowableLoader<List<PageContent>>(getActivity(), items) {

        @Override//  w w  w. ja v a 2 s.c om
        public List<PageContent> loadData() throws Exception {
            try {
                return serviceProvider.getService().getContent(getArguments().getString(GAUGE_ID));
            } catch (OperationCanceledException e) {
                Activity activity = getActivity();
                if (activity != null)
                    activity.finish();
                return initialItems;
            }
        }
    };
}

From source file:com.arthurtimberly.fragments.ErrorDialogFragment.java

@SuppressLint("NewApi")
@Override//from w w w .j  a  v a  2s .  c  o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();
    String title = args.getString(FRAGMENT_BUNDLE_KEY_TITLE);
    String message = args.getString(FRAGMENT_BUNDLE_KEY_MESSAGE);

    AlertDialog.Builder dialogBuilder = null;

    // AlertDialog.THEME_DEVICE_DEFAULT_LIGHT only available in ICS and above.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        dialogBuilder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
    } else {
        dialogBuilder = new AlertDialog.Builder(getActivity());
    }

    return dialogBuilder.setTitle(title).setMessage(message)
            .setPositiveButton(R.string.error__dialog_button_text, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    Activity activity = getActivity();
                    if (activity != null) {
                        activity.finish();
                    }
                }
            }).create();
}

From source file:codewrencher.gifit.tools.RequestPermissionConfirmationDialog.java

/**
 * On class instance created callback//from   w w  w  .  jav  a2s . co m
 * @param savedInstanceState: Stores saved parameters
 * @return
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Fragment parent = getParentFragment();
    return new AlertDialog.Builder(getActivity()).setMessage(getArguments().getString(ARG_MESSAGE))
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ActivityCompat.requestPermissions(parent.getActivity(),
                            new String[] { getArguments().getString(ARG_PERMISSION) },
                            getArguments().getInt(ARG_PERMISSION_INDEX));
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Activity activity = parent.getActivity();
                    if (activity != null) {
                        activity.finish();
                    }
                }
            }).create();
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

public static boolean isDeleteingContact(final Activity activity) {
    if (MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE)
            || MultiChoiceService.isProcessing(MultiChoiceService.TYPE_COPY)
            || VCardService.isProcessing(VCardService.TYPE_IMPORT)
            || MultiGroupPickerFragment.isMoveContactsInProcessing()// M:ALPS00567939
            || ContactSaveService.isGroupTransactionProcessing()) { // / M: Fixed ALPS00542175
        Log.d(TAG, "delete or copy is processing ");
        activity.runOnUiThread(new Runnable() {
            @Override/*from w w w .  j a  va2  s.com*/
            public void run() {
                Toast.makeText(activity.getApplicationContext(), R.string.phone_book_busy, Toast.LENGTH_SHORT)
                        .show();
            }
        });
        activity.finish();
        return true;
    }

    return false;
}

From source file:can.yrt.onebusaway.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the stop ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIHelp.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();

    } else {//ww w  .  j  a  v a2  s.co m
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:org.onebusaway.android.ui.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the route ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIUtils.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();

    } else {/*from  w  w w. java 2  s .  c  om*/
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:com.github.mobile.ui.repo.SearchRepositoryListFragment.java

/**
 * Check if the search query is an exact repository name/owner match and
 * open the repository activity and finish the current activity when it is
 *
 * @param query/*ww w .j  av a 2 s .  c om*/
 * @return true if query opened as repository, false otherwise
 */
private boolean openRepositoryMatch(final String query) {
    if (TextUtils.isEmpty(query))
        return false;

    RepositoryId repoId = RepositoryId.createFromId(query.trim());
    if (repoId == null)
        return false;

    Repository repo;
    try {
        repo = service.getRepository(repoId);
    } catch (IOException e) {
        return false;
    }

    startActivity(RepositoryViewActivity.createIntent(repo));
    final Activity activity = getActivity();
    if (activity != null)
        activity.finish();
    return true;
}

From source file:Main.java

public static void navigateUp(Activity activity, Bundle extras) {
    Intent upIntent = NavUtils.getParentActivityIntent(activity);
    if (upIntent != null) {
        if (extras != null) {
            upIntent.putExtras(extras);/*  w  ww.j av a  2 s .  c  om*/
        }
        if (NavUtils.shouldUpRecreateTask(activity, upIntent)) {
            // This activity is NOT part of this app's task, so create a new task
            // when navigating up, with a synthesized back stack.
            TaskStackBuilder.create(activity)
                    // Add all of this activity's parents to the back stack.
                    .addNextIntentWithParentStack(upIntent)
                    // Navigate up to the closest parent.
                    .startActivities();
        } else {
            // This activity is part of this app's task, so simply
            // navigate up to the logical parent activity.
            // According to http://stackoverflow.com/a/14792752/2420519
            //NavUtils.navigateUpTo(activity, upIntent);
            upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            activity.startActivity(upIntent);
        }
    }
    activity.finish();
}