Skip to content

Instantly share code, notes, and snippets.

@nisrulz
Created September 17, 2017 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nisrulz/4971c0496031322336d9ed9e0b5224d4 to your computer and use it in GitHub Desktop.
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
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