1. Check out our app, Forums for Android! Download and leave feedback here!

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

Discussion in 'Application Development' started by MIIISTER NEUGIT, Nov 12, 2010.

  1. MIIISTER NEUGIT

    Thread Starter
    15

    Nov 12, 2010
    17
    0
    15
    Xbox 360 Game Developer
    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
    53

    Aug 12, 2010
    313
    51
    53
    Norway
    You need to override the onBackPressed() method
     
    MIIISTER NEUGIT likes this.
  3. MIIISTER NEUGIT

    Thread Starter
    15

    Nov 12, 2010
    17
    0
    15
    Xbox 360 Game Developer
    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

    Thread Starter
    15

    Nov 12, 2010
    17
    0
    15
    Xbox 360 Game Developer
    Nevermind, I discovered that since I am developing for the first android I have to override onKeyDown.
     
  5. miXer

    miXer Well-Known Member
    53

    Aug 12, 2010
    313
    51
    53
    Norway
    Okey. Good to know ;)
     

Share This Page

Loading...