Android 1.6: “android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application”

后端 未结 16 1336
滥情空心
滥情空心 2020-11-22 07:46

I\'m trying to open a dialog window, but every time I try to open it it throws this exception:

Uncaught handler: thread main exiting due to uncaught exceptio         


        
16条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 07:57

    This Worked for me--

    new AlertDialog.Builder(MainActivity.this)
            .setMessage(Html.fromHtml("Spread Knowledge Unto The Last"))
            .setCancelable(false)
            .setPositiveButton("Dismiss",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                        }
                    }).show();
    

    Use

    ActivityName.this
    

提交回复
热议问题