I have a simple class that I want to use to show a Dialog message:
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();
    }
}
And I am trying to call it from my activity, within an OnClickListener event of a button, like so:
private OnClickListener btnSubmitIssueClick = new OnClickListener(){
    public void onClick(View v){
        //Check for valid Summary & 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;
        }
    }
};
But when I run it, I get this error:
03-07 16:56:00.290: W/WindowManager(169): Attempted to add window with non-application token WindowToken{4162e780 token=null}.  Aborting.
Any ideas as to what I am doing wrong?
 
     
    