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.hippo.ehviewer.EhApplication.java

@Override
public void uncaughtException(Thread thread, Throwable ex) {
    if (!handleException(ex) && mDefaultHandler != null) {
        mDefaultHandler.uncaughtException(thread, ex);
    }/*w  w  w .  j ava 2s .  co m*/

    Activity activity = getTopActivity();
    if (activity != null) {
        activity.finish();
    }

    android.os.Process.killProcess(android.os.Process.myPid());
    System.exit(1);
}

From source file:io.selendroid.ServerInstrumentation.java

public void finishAllActivities() {
    runOnMainSync(new Runnable() {
        @Override/*from w w  w .j  a v a 2 s.  co  m*/
        public void run() {
            Set<Activity> activities = getActivities();
            if (activities != null && !activities.isEmpty()) {
                for (Activity activity : activities) {
                    activity.finish();
                }
            }
        }
    });

}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onBackPressed() {
    if (select == 1 && changed == 1)
        restartPC(this);
    else if (select == 1 || select == 2) {
        selectItem(0);/*from   w w  w  . j  av  a2s  .  c  o  m*/
    } else {
        Intent in = new Intent(Preferences.this, MainActivity.class);
        in.setAction(Intent.ACTION_MAIN);
        final int enter_anim = android.R.anim.fade_in;
        final int exit_anim = android.R.anim.fade_out;
        Activity activity = this;
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.finish();
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.startActivity(in);
    }
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

public void restartPC(final Activity activity) {
    if (activity == null)
        return;/*from ww w  .  j  a  v a 2  s .  c  o m*/
    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:io.selendroid.server.ServerInstrumentation.java

private void doFinishAllActivities() {
    Set<Activity> activities = activitiesReporter.getActivities();
    if (activities != null && !activities.isEmpty()) {
        for (Activity activity : activities) {
            activity.finish();
        }/*from   ww w  .j a v a  2 s  .c om*/
    }
}

From source file:com.example.pdfviewer.PdfRendererBasicFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Activity activity = getActivity();
    try {//from  w w w .java2 s . c om
        openRenderer(activity);
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(activity, "Error! " + e.getMessage(), Toast.LENGTH_SHORT).show();
        activity.finish();
    }
    // Retain view references.
    mViewPager = (ViewPager) view.findViewById(R.id.pager);
    mPagerAdapter = new PDFPagerAdapter(getChildFragmentManager(), mPdfRenderer);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.addOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            mCurrentPage = arg0;
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });

    mButtonPrevious = (ImageButton) view.findViewById(R.id.previous);
    mButtonNext = (ImageButton) view.findViewById(R.id.next);
    // Bind events.
    mButtonPrevious.setOnClickListener(this);
    mButtonNext.setOnClickListener(this);
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        if (select == 1 && changed == 1)
            restartPC(this);
        else if (select == 1) {
            selectItem(0);//w  w w  .  j  a  va  2  s  . c  om
        } else {
            Intent in = new Intent(Preferences.this, MainActivity.class);
            in.setAction(Intent.ACTION_MAIN);
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity activity = this;
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.finish();
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.startActivity(in);
        }
        return true;

    }
    return true;
}

From source file:com.ubuntuone.android.files.fragment.SignUpFragment.java

@Override
public void onRegisterUserSuccess(String oauthData) {
    Log.d(TAG, "onRegisterUserSuccess()");

    // XXX This is dead code and needs to be removed. New user will never have
    // an account that is immediately validated after sign-up.

    final Activity activity = getActivity();
    activity.setResult(Activity.RESULT_OK);
    activity.finish();
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public void addFirstAccount(Activity activity) {
    Intent intent = new Intent(activity, WelcomeActivity.class);
    activity.startActivity(intent);
    activity.finish();
}

From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java

private void finish() {
    Activity act = (Activity) getContext();
    act.finish();
    act.overridePendingTransition(0, android.R.anim.fade_out);
}