‫Hello, my friends.
‫In this video, we are going to learn about the custom application class, why we are going to use like
‫such a class if there are tasks that need to run before the creation of the first activity.
‫We will see in this example how this works.
‫If there are static, immutable data such as shared network client docs like we have learned in that
‫the movie DB applications, if there are global objects such as data, persistence and a crash reporting,
‫this will be done in the like.
‫For example, Firebase Crash Analytics and data persistence like Chrome and the other way.
‫So we are going to learn about this app and we will see it this app class in many pro in the next project.
‫So we are going to cover all three cases.
‫For example, let's take a simple application that makes a calculation or network and network connection
‫at the first.
‫So I will create a new class.
‫How to create a Custom Application Class.
‫Start by creating a new empty class extends by application and we add the here the component of the
‫mobile, which is an interface that we have done.
‫In the previous videos that links the modules, that links with the dependencies and tells Dagur that,
‫Hey, I'm going to use all of these components and we will and you will generate for us a class that
‫helps us to make and build the clean architecture modules and make dependency injection.
‫So till now we have created an instance of the app in the on create method.
‫We need to add app equal to this and close it and we need to initialize that then mobile component.
‫So we are going to use the dagger mobile component dot, builder dot and what we are going to make,
‫we are going to make an instance of that like for example the better modal here you can make it.
‫We need to initialize all the modules here.
‫You're about to be a model.
‫I will make the percentage equal to 99.
‫Don't build.
‫Okay.
‫Here.
‫We need to make that creation of the dagger instances and the components in order to start with the
‫application.
‫Having this instance in case if you have any application connection and the application data persistence
‫that Crashlytics and the other components and and services that you need to work with before going to
‫the first activity for launching that.
‫Okay.
‫So we remove these instances from the main activities and this is a clean architecture that I, I prefer
‫using it because this app starts by own create and we need to get that app from the app class get application,
‫the get mobile component dot.
‫We can get the mobile.
‫Yeah.
‫And we start it inside.
‫In mobile instance you can make it whatever you want, what ever you, you need the things that you
‫need to, to get.
‫I get the mobile component to get mobile, but now I will make this so I'm getting mobile and here I
‫need to put inject mobile.
‫Mobile.
‫This is the field injection.
‫Okay.
‫Using the field injection.
‫Okay.
‫Remove these comments.
‫So on create method and the main activity should look like this.
‫Making an app.
‫Getting the app.
‫Get mobile component and get mobile.
‫So after that, there is a very important thing that many developers a mess is to add inside the Android
‫manifest.
‫The Android name tag and we put the app.
‫This is the name of that game.
‫Let's run the application and see if the percentage is I would remove this.
‫The percentage become 99.
‫So it will be working fine.
‫And here we go.
‫This is the tag, the percentage as 99.
‫So congratulations, guys.
‫We have added the app activity to our app, to our application.
‫And this is a very important class that we are going to learn in the next videos and we are going to
‫use in order to create a code architecture and clean code architecture apps.