There is a fragment in which the graph is built (MPAndroidChart), the data for the graph itself comes from the service (server). When the fragment is open - everything works the chart is drawn.

The essence of the problem: how to update the graph in the fragment when it is closed, and restore them when it is open?

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

You need to write data to some local storage, for example a database and build a graph using this data when calling a fragment, and not draw a graph directly in the fragment and try to draw it when it is invisible.

Or make the server give not the current value, but for the period for which the schedule is needed.

The choice of method depends on the priority tasks. The first one is much faster, the second one is much more resource-saving.