Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:49:00+00:00 2026-05-23T02:49:00+00:00

I am looking to alert the user if they hit the back button while

  • 0

I am looking to alert the user if they hit the back button while in the application.. for instance, if the user is half way through using the application and they hit the back arrow, right now it just closes and they would lose all data if they accidentally hit it.

I would like to be able to alert the user with “Do you really want to exit?” so that if it was accidental, they can choose no and continue, and not lose any data.

I’m guessing I will need to implement some sort of listener??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:49:01+00:00Added an answer on May 23, 2026 at 2:49 am

    Override onbackpressed() something like…

        @Override
        public void onBackPressed() {
            AlertDialog.Builder builder = new AlertDialog.Builder(YourActivity.this);
            builder.setMessage("Do you really want to exit?.").setCancelable(
                    false).setPositiveButton("Quit",
                            new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                                                YourActivity.this.finish();
    
                        }
                    }).setNegativeButton("Cancel",
                            new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
    
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have input-box. I'm looking for a way to fire-up alert() if first character
I'm looking to pass a user chosen value from one view to the next
I'm looking to warn the user when his or her session times out (I'm
I am looking to build a tooltip that allows the user to click links
I am really confused by looking at so many approaches the way JQuery and
guys :) I'm using local notification in my application and I provide action for
I just started looking into jQuery yesterday, before this I programmed in only PHP.
I'm looking to do long polling to push some data down to the client
Alright so here it goes, I have my user system working perfectly, and now
I am trying to make a application where a dialog will come from where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.