Created
September 17, 2017 22:35
-
-
Save nisrulz/4971c0496031322336d9ed9e0b5224d4 to your computer and use it in GitHub Desktop.
Making your Android Library, Lifecycle-Aware blog post code snippet: MainActivity class after lifecycle components have been integrated
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 MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// Add Lifecycle Observer | |
getLifecycle().addObserver(AwesomeLibMain.getInstance()); | |
} | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
// Remove Lifecycle Observer | |
getLifecycle().removeObserver(AwesomeLibMain.getInstance()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment