How can you tell if the "Back" button on the device is pressed.


Last Updated:

  1. MIIISTER NEUGIT

    MIIISTER NEUGIT Member This Topic's Starter

    Joined:
    Nov 12, 2010
    Messages:
    17
    Likes Received:
    0
    In my application I need to be able to invoke a method when the back button on the device is pressed. How do I do that?
     

    Advertisement
  2. miXer

    miXer Well-Known Member

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    You need to override the onBackPressed() method
     
    MIIISTER NEUGIT likes this.
  3. MIIISTER NEUGIT

    MIIISTER NEUGIT Member This Topic's Starter

    Joined:
    Nov 12, 2010
    Messages:
    17
    Likes Received:
    0
    Well When I put this:

    @Override
    public void onBackPressed()
    {

    }

    It gives an error and tells me to remove the @Override annotion.

    Is there any package that needs importing first?

    BTW I am developing for android 1.1
     
  4. MIIISTER NEUGIT

    MIIISTER NEUGIT Member This Topic's Starter

    Joined:
    Nov 12, 2010
    Messages:
    17
    Likes Received:
    0
    Nevermind, I discovered that since I am developing for the first android I have to override onKeyDown.
     
  5. miXer

    miXer Well-Known Member

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    Okey. Good to know ;)
     

Share This Page

Loading...