I have to extend the application class but don't know where to start.
Ok... I know this is a dumb one but I have to ask it.
I need to install LeakCanary and I see in their documentation that it requires me to put code in the Application Class.
I understand how to make a java class that extends the application class, but I have some questions before I do this.
Do I just create a new Java class in my java source folder
and name it the same as my overall package name?
If by "it", you mean the Java package, you already have a directory for your existing Java code. Put your subclass of
Application in there, unless you have a clear reason not to.
In this trivial sample app, I put my
Application subclass in the same directory as my launcher
Activity, which is the directory for my Java package (
What do I name this new class?
That is up to you. I called it
CanaryApplication. If you think you leak a lot, call it
CoalMine. So long as it is a legal Java class name, it doesn't matter.
Do I need to adjust the manifest now to have this as the entry point instead of MainActivity?
Um, well, I wouldn't describe
MainActivity as the entry point. Regardless,
MainActivity is left alone. You need to add an
android:name attribute to the
<application> element, identifying your
Do I have to change anything else in the manifest?
No, that should suffice.