NavUtils.navigateUpTo() does not start any Activity

前端 未结 9 2135
陌清茗
陌清茗 2021-01-30 06:48

I have two activities

  • MainActivity
  • DeepLinkActivity

I set up everything to use the NavUtils for navi

9条回答
  •  情话喂你
    2021-01-30 07:25

    I found the following worked for me. If the Activity was deep linked from another activity or notification the stack would be created as you navigate up otherwise, the activities are just brought to the front.

    case android.R.id.home:
    Intent upIntent = NavUtils.getParentActivityIntent(this);
    upIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(upIntent);
    finish();
    return true;
    

    Provided you have

    android:parentActivityName="parent.activity"
    

    in your manifest

提交回复
热议问题