variables retaining values after app close

前端 未结 6 642
情歌与酒
情歌与酒 2021-01-28 11:23

My app is retaining all of the variable values when it closes and this is effecting how it runs when reopened. Is there any way to reset them all upon app close? or is there a w

6条回答
  •  深忆病人
    2021-01-28 12:02

    I like what @Alex and @Jack said. To add to that, also consider that you can call finish() in your Activity if you want to force it to close up and return to the last Activity. Going along with this, also consider the use of setResult(int) (JavaDoc Here)

    You can also set a flag on the Intent when you call the Activity you are questioning about. A flag like FLAG_ACTIVITY_NO_HISTORY could be helpful:

    If set, the new activity is not kept in the history stack. As soon as the user navigates away from it, the activity is finished. This may also be set with the noHistory attribute.

    List of Intent Flags

提交回复
热议问题