开发者

Android Home button click ignoring saved state?

开发者 https://www.devze.com 2023-03-19 20:30 出处:网络
Can I ignore the previous stage of application after tapping Home b开发者_如何学Cutton in android?

Can I ignore the previous stage of application after tapping Home b开发者_如何学Cutton in android? So that I can get the application from initial screen.


Use like this.If now you are in LastActivity and you want to go back to the First Activity and there is more activity in between then if you want to go first from last use

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(autoSearch)
        if (keyCode == KeyEvent.KEYCODE_HOME) {
           Log.d("click","HOMEButtonclicked");
          LastActivity.this.startActivity(new Intent(LastActivity.this, FirstActivity.class));
           moveTaskToBack(false);
           return true;
        }
        return super.onKeyDown(keyCode, event);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消