title: Android: Show Dialog From Class
body: <p>I have written a class that extends the View class to show some data. The user needs to be able to manipulate this data by clicking on it and being presented with various options in a dialog box. </p>
  
  <p>The problem I am getting, however, is that in Android, to initialise an AlertDialog.Builder instance, you must pass in "this" (As in an activity) in order for it to work (getApplicationContext() does not work - see this article: <a href="https://stackoverflow.com/questions/5796611/dialog-throwing-unable-to-add-window-token-null-is-not-for-an-application-wi">Dialog throwing &quot;Unable to add window — token null is not for an application” with getApplication() as context</a>)</p>
  
  <p>How can I get past this problem and show the dialog from within my class that extends View?</p>