‫One of most important topics in Danaher is making diagnosing guilt so as that the name dictates singleton.
‫So we need to make it one instance of dagger while creating and dealing with.
‫And so let's create a button here in the layout I would show you without using the dagger singleton
‫and then we will modify the code in order to make it with Dagger Singleton.
‫Okay, so I will add here the button here the.
‫Their constraints, I will make it more content.
‫Right.
‫And the idea is, but in the text I will name it as go to next activity and I will create another activity
‫here inside the project.
‫In order to go towards it.
‫First, let's initialize the button.
‫Button.
‫Finding you find you buy it.
‫Bottom.
‫And putting the package button and set on click.
‫Listen our new view.
‫You view click listen and click method is override.
‫Intent or equal new intent.
‫I'm passing here the main activity that the class.
‫And what we are going to wear.
‫We are going to go we are going to go to the second activity taught class.
‫Okay.
‫And start activity and passing.
‫I.
‫To.
‫Towards it.
‫Activity.
‫Do it.
‫Okay.
‫Now let's create a new new activity.
‫Empty activity.
‫Empty activity called second activity.
‫Click.
‫Okay.
‫And I will keep it as empty activity.
‫Okay.
‫So what we will do here is logging the date of creation and the time of creation of this instance.
‫So displaying that time, the creation time of the.
‫Instance of the dagger that have been created.
‫Okay.
‫So I will create an instance from simple date format which the F equal new simple date format.
‫He.
‫This is the pattern.
‫Yes.
‫We are going to display.
‫That time.
‫The.
‫And here is the year.
‫And here we are going to display our minute and seconds.
‫Time equal to the ad for format.
‫The F making an instance from or string.
‫Called Time.
‫The F the format, the calendar.
‫Don't get instance, don't get time.
‫Now we are going to display the time method.
‫By creating it and passing the time parameter to it.
‫Towards it.
‫Okay.
‫So look, the.
‫That guy.
‫This is the tag that I'm going to show that time, the words.
‫And create creation time or instance creation time.
‫At time we are going to display at what time it have been created.
‫That's right, Nancy.
‫And here we go.
‫We have this instance created at.
‫20 to 47.
‫Okay, now.
‫So every time you call the method on create, it will create a method, another method that will instantiate
‫that a dagger instance.
‫So it's not a healthy thing that every time you click on the button you create or on create method will
‫be making an app instance.
‫Okay, so on create method every time it's called a make and you instance of the mobile component and
‫the dagger instances.
‫So let's make a singleton instance from the mobile and allow us to make sure that only one instance
‫we have during the runtime so we don't create every time a dagger classes and generate this dagger at
‫classes that we have seen in the previous videos.
‫How much how much big is your app and how many classes you have to inject and to include in the dagger
‫dependency injection?
‫It will make that new classes, instantiation and creation during the run time.
‫So this will be prevented by only creating that instance, one instance of the dagger component and
‫the dagger instances.
‫Now let's instantiate them and annotate it by singleton annotation here by the Singleton in the invitation
‫to ensure that dagger has only one dependency, one time instance, only one instance during the runtime,
‫and we prevent the memory leak that exists off network, the creation, the memory, and so on.
‫So this will make it clean architecture also.