Android android.view.windowmanager$badtokenexception progressdialog -
i try use progressdialog in button
click ,but have android.view.windowmanager$badtokenexception error. code:
starus_fail.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { dialog = progressdialog.show(getapplicationcontext(), "please wait... ", "loading... "); dialog.setprogressstyle(progressdialog.style_spinner); handler handler = new handler(); handler.postdelayed(new runnable() { public void run() { somefunction(); if (dialog != null) { dialog.dismiss(); } } }, 1000); } });
just have answer above, progressdialog uses context of activity calling it.
so pass
youractivity.this
instead of
getapplicationcontext
see www.doubleencore.in/2013/06/context/ more detailed understanding of contextual
Comments
Post a Comment