1

我已经实现了以下代码来显示自定义警报对话框,但是当我调用此对话框时,它显示异常:

WindowManager.BadTokenException

public static void showAlertDialog(final String title, String message,
            final Context context, final boolean redirectToPreviousScreen) {
        AlertDialog.Builder alertbox = new AlertDialog.Builder(context);
        alertbox.setMessage(message);
        alertbox.setTitle(title);

        alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {

            }
        });
        try{
            alertbox.show();    
        }catch (Exception b) {

        }
4

0 回答 0