Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Module
- public class AppModule {
- private Context appContext;
- public AppModule(Context appContext){
- this.appContext = appContext;
- }
- @Provides
- @Singleton
- Context provideContext(){
- return appContext;
- }
- }
- @Component(modules={ AppComponent.class })
- @Singleton
- public class AppComponent {
- void inject(MainActivity act);
- }
- public class App extends Application {
- public static AppComponent appCompanent;
- onCreate() {
- appComponent = DaggerAppComponent.builder()
- .appModule(AppModule(this))
- .build();
- }
- }
- public class MainActivity extends Activity {
- @Inject
- Context appContext;
- @Override
- void onCreate() {
- App.appCompanent.inject(this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement