progressdialog - Getting error in Progress Dialog in android? -


i have mainactivity adds fragment "a",in fragment"a" sending server request using volley.i had made class known dialogutil contain progress dialog implementation.problem when launch app shows error in progress dialog implementation in fragment "a".that

java.lang.illegalargumentexception: view=com.android.internal.policy.impl.phonewindow$decorview{42759d68 v.e..... r......d 0,0-456,144} not attached window manager , becomes force close.

dialogutil class code:-

   public class dialogutils {      public static progressdialog showprogressdialog(context context, string message) {         progressdialog m_dialog = new progressdialog(context);         m_dialog.setmessage(message);         m_dialog.setprogressstyle(progressdialog.style_spinner);         m_dialog.setcancelable(false);         m_dialog.show();         return m_dialog;     } } 

progress dialog implementation in fragment "a"

m_dialog = dialogutils.showprogressdialog(getcontext(), "loading...");          final string m_deallistingurl = "http://202.131.1.132:8080/ireward/rest/json/metallica/getdeallistinjson";         jsonobjectrequest jsonobjectrequest = new jsonobjectrequest(request.method.post, m_deallistingurl, jsonobject, new response.listener<jsonobject>() {             @override             public void onresponse(jsonobject response) {                 log.i(tag, "server response:-" + response);                 if (m_dialog != null && m_dialog.isshowing()) {                     m_dialog.dismiss();                 } 

try this:

dialogutils.showprogressdialog(getactivity(), "loading..."); 

use getactivity() instead of getcontext()


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -