Removing extras from passed-in Intent

前端 未结 3 904
天命终不由人
天命终不由人 2021-02-01 00:22

I have a search screen which can be launched from clicking on a \"name\" field of another screen.

If the user follows this workflow, I add an extra to the Intent\'s Extr

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 00:51

    I have it working.

    It appears getExtras() creates a copy of the Intent's extras.

    If I use the following line, this works fine:

    getIntent().removeExtra("search");
    

    Source code of getExtras()

    /**
     * Retrieves a map of extended data from the intent.
     *
     * @return the map of all extras previously added with putExtra(),
     * or null if none have been added.
     */
    public Bundle getExtras() {
        return (mExtras != null)
                ? new Bundle(mExtras)
                : null;
    }
    

提交回复
热议问题