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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:52:26+00:00 2026-05-24T04:52:26+00:00

In my application I have only one activity and I am using ViewAnimator for

  • 0

In my application I have only one activity and I am using ViewAnimator for changing the screen. For the Menu and Back Keys I am trying to pause the activity (like home key does) and show a menu or go back to previous View.

Angry Birds do the same think (Angry Birds Rio do exactly the same thing what I want).

I have also checked the OnKeyDown event to find out how the Home key work but I think it is handled by the system.

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/app/Activity.java#Activity.onKeyDown%28int%2Candroid.view.KeyEvent%29

Thanks.

  • 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-24T04:52:28+00:00Added an answer on May 24, 2026 at 4:52 am

    In order to catch the menu key:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //return true to show some menu
        //return false to not show any menu
    }
    

    Read more here: http://developer.android.com/reference/android/app/Activity.html#onCreateOptionsMenu(android.view.Menu)

    Ir order to catch the back key event:

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            //do your stuff and Return true to prevent this event from being propagated further
            return true;
        }
    
        return false;
    }
    

    Read more here: http://developer.android.com/reference/android/app/Activity.html#onKeyUp(int, android.view.KeyEvent)

    EDIT:
    Pausing your application’s logic is up to you. But you can show an AlertDialog with up to three buttons and/or any View you want: http://developer.android.com/reference/android/app/AlertDialog.html

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

Sidebar

Related Questions

I'm writing my first Android application and I have one activity that I'd like
I need to make so that my application can have only one instance running
I have an application which may only have one instance of itself open at
I have a UINavigationBar based application - only a one navigation bar that is
My Application have 5 activities(A1,A2,A3,A4,A5). Each activity have one text view and one button(B1,B2,B3,B4,B5).
I've been using Android for only a little while. In my application, I have
I have a very simple game that consists of only one activity, and I
In My application i am using two list view's in one activity, one for
When creating an Android application using Loaders, should every activity and fragment have its
I have only just started received the following error in my windows forms application

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.