我正在覆盖此功能:

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event)


但是,有没有办法确定后退按钮将带用户到哪个Intent或屏幕?

最佳答案

您最好将信息添加到启动当前活动的意图中。

活动A

    Intent lIntent = new Intent();
    lIntent.putExtra( EXTRAS_ACTIVITY_KEY, ACTIVITY_IDENTIFIER );
    startActivitiy...


活动B

    public boolean onKeyUp(int keyCode, KeyEvent event){
           Intent lIntent = getIntent();
           if(lIntent.hasExtra(EXTRAS_ACTIVITY_KEY) &&
                   ACTIVITY_IDENTIFIER.equals(lIntent.getStringExtra(EXTRAS_ACTIVITY_KEY)){
                   // Great we know that it was a Activity A...
                   ... your code here....
           }

10-07 12:40