Is there anyway to know that a Fragment has finish loading the entire contents of the Fragment?
The reason I'm asking is because in the onResume state when I put the application in the background I Re-Load the Fragment by executing an AsyncTask but I only want to Re-Load the Fragment that was put in the background only if the Fragment has not finished loading the entire contents of the layout (images, shapes, data, etc...)
is there anyway to know if the Fragment has been fully loaded?
Fragments. A Fragment represents a reusable portion of your app's UI. A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events. Fragments cannot live on their own--they must be hosted by an activity or another fragment. The fragment’s view hierarchy becomes part of, or attaches to , ...
You can know the following with the built in method called "onActivityCreated (Bundle)" this method tells that the fragment has been created thus you get to know that the fragment appears on the screen Click here for reference Hope it helps I've looked through what's available without using a base Fragment or Activity class but couldn't find any.
A result is received if the Fragment’s lifecycle is at least in the started state If multiple data is passed to the Fragment before it reaches the STARTED state, it’ll only receive the latest value if it eventually reaches the STARTED state. The latest result is received when the Fragment’s lifecycle reaches the started state
They do most everything through their FragmentManager, and propagate their own lifecycle callbacks down to the Fragments so that the fragments will behave appropriately. The onResume and onPause callbacks in fragments only occur when they are first created or when the Activity experiences those callbacks.
If u just want to know when your Fragment layout is fully inflated u might want to use onActivityCreated(Bundle savedInstanceState) that is called after onCreate and onCreateView.
You can find more information about Fragment life-cycle here
Anyway, if u want more accurate answer post some of your code and make and example to better describe your purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With