Dialog throwing “Unable to add window — token null is not for an application” with getApplication() as context

My Activity is trying to create an AlertDialog which requires a Context as a parameter. This works as expected if I use: However, I am leery of using “this” as a context due to the potential for memory leaks when Activity is destroyed and recreated even during something simple like a screen rotation. From a … Read more