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:org.kontalk.ui.StatusFragment.java

private void finish(String text) {
    Activity parent = getActivity();

    if (parent != null) {
        if (text.trim().length() <= 0)
            text = text.trim();//from w ww.j a v  a 2 s . c o  m
        Preferences.setStatusMessage(text);
        Preferences.addRecentStatusMessage(parent, text);

        // start the message center to push the status message
        MessageCenterService.updateStatus(parent);

        parent.finish();
    }
}

From source file:com.ui.UiActivity.java

public void startActivity(Context context, Class<?> zls, final Map<String, String> intentParameter) {

    Activity activity = ((Activity) context);
    Intent intent = (Intent) activity.getIntent();
    intent.setClass(context, zls);/*from ww  w. ja  v  a  2  s  .c  om*/
    if (null != intentParameter) {
        for (Map.Entry<String, String> entry : intentParameter.entrySet()) {
            intent.putExtra(entry.getKey(), entry.getValue());
        }
    }
    activity.startActivity(intent);
    activity.finish();
}

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

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

}

From source file:com.wifiafterconnect.DisableWifiDialogFragment.java

protected void performAction(WifiTools.Action action) {
    Activity activity = getActivity();
    DisableWifiDialogListener listener = (DisableWifiDialogListener) activity;
    if (activity != null) {
        action.perform(activity);/*ww w . j  a  v a2 s .c  o  m*/
        if (listener != null) {
            CheckBox checkAlways = (CheckBox) activity.findViewById(R.id.checkAlwaysDoThat);
            if (checkAlways != null && checkAlways.isChecked())
                listener.saveAction(action);
        }
        activity.finish();
    }
}

From source file:com.example.android.pdfrendererbasic.PdfRendererBasicFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {//from  ww w  .  j  av a  2 s.  c  om
        openRenderer(activity);
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(activity, "Error! " + e.getMessage(), Toast.LENGTH_SHORT).show();
        activity.finish();
    }
}

From source file:com.nextgis.maplibui.fragment.NGIDLoginFragment.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.signin) {
        boolean loginPasswordFilled = checkEditText(mLogin) && checkEditText(mPassword);
        if (!loginPasswordFilled) {
            Toast.makeText(getActivity(), R.string.field_not_filled, Toast.LENGTH_SHORT).show();
            return;
        }//from www  .ja v  a 2  s. c  om

        IGISApplication application = (IGISApplication) getActivity().getApplication();
        application.sendEvent(ConstantsUI.GA_NGID, ConstantsUI.GA_CONNECT, ConstantsUI.GA_USER);
        mSignInButton.setEnabled(false);
        final Activity activity = getActivity();
        NGIDUtils.getToken(activity, mLogin.getText().toString(), mPassword.getText().toString(),
                new NGIDUtils.OnFinish() {
                    @Override
                    public void onFinish(String data) {
                        mSignInButton.setEnabled(true);

                        if (data == null)
                            activity.finish();
                        else
                            Toast.makeText(activity, NetworkUtil.getError(activity, data), Toast.LENGTH_SHORT)
                                    .show();
                    }
                });
    } else if (v.getId() == R.id.signup) {
        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://my.nextgis.com"));
        startActivity(browser);
    }
}

From source file:com.nextgis.libngui.fragment.NGIDLoginFragment.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.signin) {
        boolean loginPasswordFilled = checkEditText(mLogin) && checkEditText(mPassword);
        if (!loginPasswordFilled) {
            Toast.makeText(getActivity(), R.string.field_not_filled, Toast.LENGTH_SHORT).show();
            return;
        }// w w  w  .j a  v  a 2 s.  c  om

        mSignInButton.setEnabled(false);
        final Activity activity = getActivity();
        NGIDUtils.getToken(activity, mLogin.getText().toString(), mPassword.getText().toString(),
                new NGIDUtils.OnFinish() {
                    @Override
                    public void onFinish(String data) {
                        mSignInButton.setEnabled(true);

                        if (data == null) {
                            activity.finish();
                        } else {
                            Toast.makeText(activity, NetworkUtil.getError(activity, data), Toast.LENGTH_SHORT)
                                    .show();
                        }
                    }
                });
    } else if (v.getId() == R.id.signup) {
        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://my.nextgis.com"));
        startActivity(browser);
    }
}

From source file:at.bitfire.davdroid.ui.CreateCollectionFragment.java

@Override
public void onLoadFinished(Loader<Exception> loader, Exception exception) {
    dismissAllowingStateLoss();//from  ww  w.  j  a  va2  s  .  c om

    Activity parent = getActivity();
    if (parent != null) {
        if (exception != null)
            getFragmentManager().beginTransaction()
                    .add(ExceptionInfoFragment.newInstance(exception, account), null).commitAllowingStateLoss();
        else
            parent.finish();
    }

}

From source file:it.scoppelletti.mobilepower.app.data.DatabaseConnectionManager.java

/**
 * Gestisce l&rsquo;interruzione dell&rsquo;aggiornamento del database. 
 *//* ww w .j a v  a 2s .  com*/
public void onCancel(DialogInterface dialog) {
    Activity activity;

    if (myUpgradeTask != null) {
        myUpgradeTask.cancel(true);
        myUpgradeTask = null;
    }

    if (myDb != null) {
        myDb.close();
        myDb = null;
    }

    activity = myActivity.asActivity();
    if (!activity.isFinishing()) {
        activity.finish();
    }
}

From source file:org.traccar.manager.DevicesFragment.java

private void finishDevicesActivity(long deviceId, String deviceStatus) {
    Activity activity = getActivity();
    Intent deviceIntent = new Intent();
    deviceIntent.putExtra(EXTRA_DEVICE_ID, deviceId);
    deviceIntent.putExtra(EXTRA_DEVICE_STATUS, deviceStatus);

    //activity.setResult(MainFragment.RESULT_SUCCESS, new Intent().putExtra(EXTRA_DEVICE_ID, deviceId ));
    activity.setResult(MainFragment.RESULT_SUCCESS, deviceIntent);
    activity.finish();
}