

When you click this button you will notice in your Logcat : This is just an implicit intent to send some data to someone else. To test this just add a button to your fragment layout and on its Click Listener write the following code : Implicit Intent That makes things a little clearer, but are onPause() and onResume() only called with other methods? No, onPause() is called when the app loses focus and OnResume() is called when it is in focus. Now if you minimize your app you will notice :Īnd if you open it again you will notice : When you open your fragment you will notice these in your Logcat :įragment LifeCycle: onViewCreated Called! So open your fragment and override the above methods like this :

Now that we know what the LifeCycle looks like, let’s understand it. In activities we use the onCreate() Method to inflate the layout and bind views while in case of fragments the layout is inflated in onCreateView() Method and we bind views in the onViewCreated() method. What’s the difference then? Well, a major one would be : Fragments have similar lifecycles to Activities. If you are thinking “ That looks like the Activity LifeCycle! ”, then yes you are right. It looks something like this : Fragment LifeCycle But have you heard about the Fragment LifeCycle?

If you have experimented with making an app, chances are you have probably used Fragments.
