Created
July 1, 2019 14:19
-
-
Save Rapbong/db28182226c2c3ce616e48ba5ead3cab to your computer and use it in GitHub Desktop.
Dagger2 document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FrombulationActivity extends Activity { | |
@Inject Frombulator frombulator; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// DO THIS FIRST. Otherwise frombulator might be null! | |
((SomeApplicationBaseType) getContext().getApplicationContext()) | |
.getApplicationComponent() | |
.newActivityComponentBuilder() | |
.activity(this) | |
.build() | |
.inject(this); | |
// ... now you can write the exciting code | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment