How to clear arguments in Fragment?

后端 未结 5 1414
Happy的楠姐
Happy的楠姐 2021-02-20 01:58

I have an AudioPlayerFragment to which I pass some url with setArguments().

If I have an url key in the getArguments() of my insta

5条回答
  •  Happy的楠姐
    2021-02-20 02:09

    Make sure you are reading getArguments() in onCreate() method of the fragment. Once the fragment was created, when going back you souldn't pass trough onCreate(), so you shouldn't be able to read again the arguments.

    If this still does not work, you could make use of a boolean flag and read the arguments only once.

    Something like this:

    if(!argumentsRead){
    
        // read arguments
    
        argumentsRead = true;
    }
    

提交回复
热议问题