Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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