Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this blog, we will implement the dagger 2 dependency injection and before we start we will take a look at annotation type which we are going to use in this blog.
Add dependency in your buid.gradle:
1-AppModule.class
AppModule class will be used to provide this reference. We will define a method annotated with @Provides @Singleton that informs Dagger that this method is the constructor for the String return type ( it is the method in charge of providing the instance of the String).
2-AppComponent.class
In AppComponent class where we define the class where we will inject the modules it’s basically the bridge between Module and the class which injecting the module.
Build your project, In your MainActivity class to inject the dependency add @Inject annotation on the String object.
I hope it will help you to give the basic idea of how it will make your project component reusable and inject dependency of the object whenever it required by class.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.
Josh Arnold
Owner, Shop ATV Escape
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.