Android - Show Dialog from static class
<p>I have a simple class that I want to use to show a Dialog message:</p>

<pre><code>public class Utils {

    static void ShowMessage(Context c, String DialogTitle, String MessageToDisplay, int LayoutResourceID, int ImageResourceID ){

        //Create new dialog.
        Dialog dialog = new Dialog(c);

        //Set the view to an existing xml layout.
        dialog.setContentView(LayoutResourceID);
        dialog.setTitle(DialogTitle);

        //Set textbox text and icon for dialog.
        TextView text = (TextView) dialog.findViewById(R.id.text);
        text.setText(MessageToDisplay);
        ImageView image = (ImageView)dialog.findViewById(R.id.image);
        image.setImageResource(ImageResourceID);

        //Show the dialog window.
        dialog.show();
    }
}
</code></pre>

<p>And I am trying to call it from my activity, within an OnClickListener event of a button, like so:</p>

<pre><code>private OnClickListener btnSubmitIssueClick = new OnClickListener(){

    public void onClick(View v){
        //Check for valid Summary &amp; Description.
        if(mSummaryEditText.getText().toString().trim().length() == 0){
            Utils.ShowMessage(getBaseContext(), "Submit Issue Error", getBaseContext().getString(R.string.ERROR_SummaryRequired),
                    R.layout.modal_dialog, R.drawable.warning);
            return;
        }else if(mDescriptionEditText.getText().toString().trim().length() == 0){
            Utils.ShowMessage(getBaseContext(), "Submit Issue Error", getBaseContext().getString(R.string.ERROR_DescriptionRequired),
                    R.layout.modal_dialog, R.drawable.warning);
            return;
        }
    }
};
</code></pre>

<p>But when I run it, I get this error:</p>

<pre><code>03-07 16:56:00.290: W/WindowManager(169): Attempted to add window with non-application token WindowToken{4162e780 token=null}.  Aborting.
</code></pre>

<p>Any ideas as to what I am doing wrong?</p>
