how to close application when home button is clicked

Put your problem here if it does not fit any of the other categories.

how to close application when home button is clicked

Postby chinnu » Thu Nov 26, 2009 1:57 pm

hai this is chinnu.
my problem is closing application when BACK or HOME button is clicked.
i used onKeyDown method
my code is:

public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
Log.i("onkeydown","this is BACK button ");
this.setResult(10);
this.finish();
Log.i("onkeydown","finishing the activity ");
break;
case KeyEvent.KEYCODE_HOME :
Log.i("onkeydown","this is HOME button ");
this.setResult(10);
this.finish();
break;
}}
this is working for back button,
MY PROBLEM IS THIS CODE IS NOT ENEN PRINTING THE LOG MSG WHEN I PRESSED "HOME" BUTTON.
so i'm unable to close my application.
plz help me.
chinnu
Freshman
Freshman
 
Posts: 2
Joined: Thu Aug 27, 2009 6:08 am
Location: hyderabad

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests