i want to if the user press home button my service will be stop , this is my code but it's not working for me, please help me:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
stopService(new Intent(this, MyService.class));
return true;
}
return super.onKeyDown(keyCode, event);
}
Thanks
See Question&Answers more detail:os