I have a fragment which shows a line chart created with MPAndroidChart. Loading the fragment takes about 200 milliseconds.
I want to improve the perceived app performance by loading the chart data data right after the fragment becomes visible.
Therefore I need to execute code right after the fragment becomes visible, but only the FIRST time it becomes visible.
I can not use onResume(), since it gets called just before the fragment is visible.
Note: I can not use an asynchrounous task, it needs to be done on the UI-thread.
onResume
or the Activity'sonResume
?onResume
. That method gets called after the Fragment becomes visible.onCreateView
is the way to go