exit app android

 @Override
    public void onBackPressed() {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("Exit Application?");
        alertDialogBuilder
                .setMessage("Click yes to exit!")
                .setCancelable(false)
                .setPositiveButton("Yes",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                moveTaskToBack(true);
                                android.os.Process.killProcess(android.os.Process.myPid());
                                System.exit(1);
                            }
                        })

                .setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {

                        dialog.cancel();
                    }
                });

        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }

5
2
T.R. 90 points

                                    public void onBackPressed() {
  moveTaskToBack(true);
  android.os.Process.killProcess(android.os.Process.myPid());
  System.exit(1);
}

5 (2 Votes)
0
0
0

                                    ActivityName.this.finish();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
android how to close app android how to close app from application class how to exit android app how to close applications on android close app android manually exit application android exit from app android studio close the android app android quit app android close application code make the program do something on exit android studio android java close application android close application android java exit android exit code exit app java android android do something on exit close app java android studio android on application close exit from application android close app completely android close the app android how to exit from app in android studio how to exit application in android android exit app completely close apps on android how to exit app in android studio exit an android app Android exit application exit in android studio android studio exit app close app in android android java close app how to close app in android how to exit an app in android studio how to exit app android studio how to exit app in android how to exit the app in android studio app exit android android studio close app java android close app java android close app exit app android how to implement app exit in android android app exit exit app in android exit app in android studio close app android java android exit app how to close app android how to close app in android programmatically close android app how close application java android close app completely in android code close the app also in the background close exit application android app close the background app in the android exit from app java android exit application android programmatically exit application android how to close app from backgtound on android exit app android studio intent exit application code exit program android studio android method when close or finish application exit from programmically close app programmatically android how ot close application android studio kill a app using android code exit java android how to code an application exit in android studio using java android studio close app completely exit button close application in android studio close app android studio quit android app programmatically android studio quit application Exit program Android
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source