Setting up Dagger 2 injection for inheritance situations with Android activities or fragments can be a pain. This article explains it simply with an example.

Suppose you have a BaseActivity that you need to extend. Let’s call the extending class SubClassedActivity.

Steps

First, contribute the android injector for the subclassed activity.

Kelvin Watson

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store