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

  • SEARCH
  • Home
  • 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 4235570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:31:01+00:00 2026-05-21T02:31:01+00:00

I am trying to handle the back button event on my app but its

  • 0

I am trying to handle the back button event on my app but its not working at all. I have inplemented ActivityGroup in my app according to the post Android: TabActivity Nested Activities

I have added the following code according to many posts in this website

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.d(this.getClass().getName(), "back button pressed: " + keyCode);
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        Log.d(this.getClass().getName(), "back button pressed");
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

but for some reason i still dont know i am not getting the lines to be logged, it goes back to the home screen. I know that the onBackPressed will not work for me because I need to have this app implemented using api level 4 and it is not available at this level.

My ActivityGroup has only two activities, one list view and a details view. I have put this code on all the three classes to try something different, but still cant get it working. I see “No keyboard for id 0” in the logs, but i dont think it means something that can be related to the problem.

I do appreciate any answer to this.
Many thanks
T

  • 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-21T02:31:02+00:00Added an answer on May 21, 2026 at 2:31 am

    Add a log statement right above the return line and see what KeyEvent is happening.

    like this:

    Log.w(keyCode, "This is the key code that is returned");
    return super.onKeyDown(keyCode, event);
    

    Now look at the returned value and verify/compare it to KeyEvent.KEYCODE_BACK and this may point you in the direction of your problem.

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

Sidebar

Related Questions

Back with another one. Trying to get what little app I have to cooperate
I'm trying to handle a JSONP Callback, I have the following JavaScript var URL
I've been trying to handle the onkeydown event across multiple frames (no, I unfortunately
I am trying to handle the click of custom button in a jqgrid. I
Typically.NET handles the post back event on a button by making the button a
I'm using a new item Basic Template with the app name and back button.
I'm trying to streamline my login system by using ajax to handle to back
I have a multipage form, with back buttons, and I'm trying to have a
I am trying to handle an array coming back from an ajax call. My
I know that ASP.NET controls such as the button have the postback event model.

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.