Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Last active June 10, 2022 10:15
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 frogermcs/f23d071438e98b2383ed44f759505607 to your computer and use it in GitHub Desktop.
Save frogermcs/f23d071438e98b2383ed44f759505607 to your computer and use it in GitHub Desktop.
public abstract class BaseActivity extends AppCompatActivity {
@Inject
AnalyticsTools analyticsTools;
@Override
protected void onStart() {
super.onStart();
trackScreenView();
}
protected void trackScreenView() {
String screenName = getScreenNameForAnalytics();
analyticsTools.logScreenLaunch(screenName);
}
@Override
protected void onDestroy() {
super.onDestroy();
//Your screen is being destroyed. It's a good time to let your analytics tools know
//that it would be safe to send all events and release the queue
analyticsTools.flush();
}
public abstract String getScreenNameForAnalytics();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment