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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:24:37+00:00 2026-06-10T01:24:37+00:00

My question is self explanatory. I have searched a lot but could not found

  • 0

My question is self explanatory.
I have searched a lot but could not found the way to handle Recent activity button click.
I want to ignore the hardware button clicks of Recent Activity button from the status bar from android 3.0 tablet.

Currently what I have tried so far is:

public boolean onKeyDown(int keyCode, KeyEvent event) {

       if(keyCode == KeyEvent.KEYCODE_BACK) 
       { 
              return true;
       }
       // in the same way I have written it for KEYCODE_HOME
}

can you tell me what should I write to handle recent activity button?

Thanking you in advance. 🙂

EDIT: This is what I have tried now. The KEYCODE_APP_SWITCH is not working.

public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.e("INSIDE", "LOCKDEMO");
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Log.e("KEY EVENT", "BACK");
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_HOME) {
            Log.e("KEY EVENT", "HOME");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_FROM_SYSTEM) {
            Log.e("KEY EVENT", "SYSTEM");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_KEEP_TOUCH_MODE) {
            Log.e("KEY EVENT", "TOUCH MODE");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_SOFT_KEYBOARD) {
            Log.e("KEY EVENT", "SoFT KEYBOARD");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_VIRTUAL_HARD_KEY) {
            Log.e("KEY EVENT", "HARDWARE KEY");
            return true;
        }
        if(keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
            Log.e("KEY EVENT", "APP SWITCH");
            return true;
        }

        Log.e("KEY EVENT", "NOT HANDLED");
        return super.onKeyDown(keyCode, event);
    }

When I press on RecentAppBtn, it does not even print the last Log statement i.e. Event not handled.

  • 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-06-10T01:24:39+00:00Added an answer on June 10, 2026 at 1:24 am

    From peeking into the docs, I think that KeyEvent.KEYCODE_APP_SWITCH is what you’re searching for.

    You could however also use the KeyEvent.getKeyCode()-method (on the event-parameter) to see which key-code is triggered (and if there is any key triggered), when you press the application switcher.


    I played around with this for a while and I have come to the conclusion, that it’s not possible.

    The KEYCODE_APP_SWITCH-event is not delivered to either onKeyDown() nor dispatchKeyEvent(). Ergo, It can not be handled.

    Also, you’ll run into problems on Android 4 devices, because the KEYCODE_HOME-event is also no longer dispatched to any of the above methods. See the docs:

    Key code constant: Home key. This key is handled by the framework
    and is never delivered to applications
    .


    It also seems that there is no real easy approach to creating a real lock-screen yourself. See this discussion: Developing a custom lock screen

    It is well possible to show some custom information on the default lock-screen: Is there a way for me to show a customized message on the lock screen?


    For the sake of completeness: In Android L, you’ll be able to “lock users in your app”, so you don’t need to manually override the Hardware keys. Here’s the relevant information:

    The L Developer Preview introduces a new task locking API that lets
    you temporarily restrict users from leaving your app
    or being
    interrupted by notifications. This could be used, for example, if you
    are developing an education app to support high stakes assessment
    requirements on Android. Once your app activates this mode, users will
    not be able to see notifications, access other apps, or return to the
    Home screen, until your app exits the mode.

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

Sidebar

Related Questions

Well the question is self explanatory! but the thing is I have no experience
The question is self explanatory. Could you please point out a way to put
The title of this question should be self explanatory, but basically I have this
Maybe the title of the question is not very self-explanatory but I don't know
Question should be self explanatory. I have a datagridview which has a column whose
Maybe the question is not self-explanatory, so I will explain it through. The deal
Well my question is pretty self-explanatory. I have a class and I want to
The question is self-explanatory. But to complement suppose: map<int,int> with at least 10 inserted
Just starting programming, so don`t kick too hard, question is pretty self explanatory, but
Well the question title may not be self explanatory, so let me go ahead

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.