Android onPreExecute cannot show a ProgressDialog -


so, have asynctask below:

private class asyncretriever extends asynctask<iotdhandler,void,iotdhandler>{         progressdialog pdialog;         @override         protected void onpreexecute(){             pdialog = new progressdialog(getapplicationcontext());             pdialog.setmessage(getresources().getstring(r.string.toast_msg1));             pdialog.show();         } //------------------------------------------------------------------------------   

this inner class of mainactivity. however, logcat flags pdialog.show() error.
says, unable start activity componentinfo.

how solve this?

a progressdialog needs activity context. try this:

pdialog = new progressdialog(youractivity.this); 

Comments

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -