I noticed that using the shortcut Alt + Insert
and selecting the builders, it tries to create a constructor with each private property (e.g. cManager
Android activities can have constructors as long as they take zero arguments. And in fact there is such a constructor as soon as you initialize any field when declaring it.
But as your log says, System services not available to Activities before onCreate()
, so you can't call getSystemService
from the constructor.
So the code in https://stackoverflow.com/a/28636652/53974 is correct, but the reason isn't.