Can one show a dialog in superclass?
<p>I have a subclass of ListActivity that is reused throughout my project, subclassed again so that each reports to a different ActivityGroup. This is working beautifully until I try to present a dialog in the superclass (as this behaviour should be exhibited by each subclass), and I get the following error:</p>

<pre><code> ERROR/AndroidRuntime(31514): FATAL EXCEPTION: main
 ERROR/AndroidRuntime(31514): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
</code></pre>

<p>Now, I think this is due to the context that is being fed into the AlertDialog.Builder. I am using standard sample code from <a href="http://developer.android.com/guide/topics/ui/dialogs.html" rel="nofollow">Google</a>. Any ideas appreciated.</p>

<pre><code>final CharSequence[] items = {"Red", "Green", "Blue"};

AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
    Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
alert.show();
</code></pre>
