0

I have an android application implementing facebook.It shows facebook login dialog(extends dialog) when click on a button from an activity.

If we pressing home button after loading the facebook dialog, the application exits.But if we restart the application it shows the dialog instead of activity. I am using this in my Dialog class

public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK){
            mSpinner.dismiss();
            mListener.onCancel();
            FbDialog.this.dismiss();
        }

        return super.onKeyUp(keyCode, event);
    }

From my googling i can find out that we could not obtain Home Button click.

Then how can i exit and finish all the activities with Home button click?

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
Asha Soman
  • 302
  • 2
  • 6
  • 18

4 Answers4

0

You can use:

android.os.Process.killProcess(android.os.Process.myPid());

in your onKeyUp method

Casabian
  • 308
  • 2
  • 8
0

Home button click does not exit the application, it only sends it to the background..

Nermeen
  • 15,883
  • 5
  • 59
  • 72
0

It's bad for click on home button and exit but I don't know whats your real requirement. You can detect the home button pressed by onkey(). Implement the onkey() and check the key pressed is home key or not. If it's home key then call finish() other do nothing.

Home button actually used for to pause your current activity and go to the home button. For exit current activity we use the back button.

Pratik
  • 30,639
  • 18
  • 84
  • 159
  • yes I am also talk on user perspective way not by the app developer. If it real way need to exit from application from back button and also when use press the home button then you can used it. – Pratik Sep 20 '12 at 08:00
0

I would suggest a bit of a workaround for this.As I don't know your exact requirements, I cannot be specific. 1.Create an activity and finish it inside the onCreate method. 2.Call that activity using an intent(set the intents property to FLAG_ACTIVITY_CLEAR_TOP) when the home button is clicked.

anz
  • 1,317
  • 2
  • 13
  • 25