How to navigate up to the same parent state

前端 未结 5 650
清歌不尽
清歌不尽 2020-12-02 13:08

From my observation from Gmail and TED app the behavior of up navigation it will navigate to parent with the same state (scroll position) not like what Google say in their d

5条回答
  •  隐瞒了意图╮
    2020-12-02 13:54

    The "standard" behaviour for an android activity is, that a new instance of the activity is created, every time there is a new intent for this activity (see launchMode-docu here). Because of this your extras seem to be gone, if you call navigateUpTo.

    In your case, I would advise to use

    android:launchMode="singleTop"
    

    for your parent activity in your AndroidManifest.xml. This way you will return to your existing activity (as long as it is on the top of the back stack of your task). This way your extras will be preserved.

    I too, do not understand why this is not mentioned in the Google doc you cite, as this seems the behaviour one expects if using up-navigation.

提交回复
热议问题