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 4102074
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:46:44+00:00 2026-05-20T20:46:44+00:00

Which is the function called when you click the back button on android. My

  • 0

Which is the function called when you click the back button on android. My requirement is when an application is running and user clicks on the back button, the status of the application should be stored into the database and the user should be able to see the status whenever he returns back to the application.

Browsing through internet, I understood we can handle the control using onKeyDown() function. However even if I use it in my code, the function is not called when I click on back button. Below is the function:

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      Log.d(null,"In on Key Down");
      if (keyCode == KeyEvent.KEYCODE_BACK) {
          moveTaskToBack(true);
          return true;
      }
      return super.onKeyDown(keyCode, event);
  }

Please suggest, if anybody has faced the same/similar scenario.

  • 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-20T20:46:45+00:00Added an answer on May 20, 2026 at 8:46 pm

    Use the Activity lifecycle methods to save and restore state. You could save your state during onPause and restore in onResume. In your activity:

     @Override
    protected void onPause()
    {
    super.onPause();
        //Save state here
    }
    
    @Override
    protected void onResume()
    {
    super.onResume();
        //Restore state here
    }
    

    You could also do this in onStart/onStop. Check out the activity lifecycle here: http://developer.android.com/reference/android/app/Activity.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in javascript called dumpData which I call from a button
I have a function which calculates distance from database records. This function is called
hi i have function which is called by tinker listbox so i cannot return
Heres my custom function called doIt which as im sure you can see simply
I am using a library function called get_count_and_price which returns a 2-tuple (count,price). In
I have a function called PreProcessSource, which allocates a boost::wave::context and does some preprocessing;
I am using jQuery(Latest release) and have a function called calculate() which gets called
Now I'm sure this is super easy, I have a function called remove_deposit which
Can I define a function which, when called, inserts new locals into the caller's
How can I check which event called my function on JavaScript with jQuery? Like

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.