NavUtils.shouldUpRecreateTask fails on JellyBean

后端 未结 3 1383
我在风中等你
我在风中等你 2021-02-13 10:22

I have an application that issues notifications that when selected start an activity. According to the Android docs I can use NavUtils.shouldUpRecreateTask to check whether the

3条回答
  •  旧巷少年郎
    2021-02-13 10:43

    I had the same problem as OP. NavUtils.shouldUpRecreateTask always seemed to return false. (JellyBean also) I used the following the achieve the same functionality.

    case android.R.id.home:
    Intent upIntent = new Intent(this,ParentActivity.class);
    upIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(upIntent);
    finish();
    return true;
    

    The 'parent' intent could be fetched this way instead of hard coding.

    Intent upIntent = NavUtils.getParentActivityIntent(this);
    

提交回复
热议问题