android - AsyncTask publishProgress dont call onProgressUpdate -


i have similar threads issue, couldn't find solution problem

my asynktask should download file dropbox , display progress in notification progressbar. doinbackground download file method publishprogress / onprogressupdate not work correctly. onprogressupdate not getting called.

asynctask

public class songdownload extends asynctask<string, string, string> {      dropboxapi<androidauthsession> ddbapi;     context context;     dropbox db;     sharedpreferences prefs;     notificationmanager mnotifymanager;     notification notification;     string datei;      public songdownload(context context, dropbox db) {         this.db = db;         this.context = context;         log.v("mp3dropboxsync", "songdownload");          mnotifymanager = (notificationmanager) context.getsystemservice(context.notification_service);         notification notification = new notification(r.drawable.ic_launcher, "neuer dropbox song!", system.currenttimemillis());          remoteviews views = new remoteviews(context.getapplicationcontext()                 .getpackagename(), r.layout.notiprogressbar);         views.setprogressbar(r.id.progressbar1, 100, 0, false);         views.settextviewtext(r.id.status_text, "song downloading...");          notification.contentview = views;          notification.flags |= notification.flag_auto_cancel | notification.flag_ongoing_event;          mnotifymanager.notify(10, notification);      }  @override protected string doinbackground(string... dropboxfile) {      log.v("mp3dropboxsync", "doinbackground");     file file = new file(environment.getexternalstoragedirectory().getpath()+"/mp3/sonstiges/"+dropboxfile[0]);     datei = dropboxfile[0];     bufferedoutputstream out=null;     try {          if(!file.exists())         {          out = new bufferedoutputstream(new fileoutputstream(file));         db.mdbapi.getfile("/mp3/"+dropboxfile[0], null, out, new progresslistener() {              @override             public void onprogress(long bytes, long total) {                  try {                     log.v("mp3dropboxsync", "onprogress");                     string s = ""+(bytes/(float)total)*100;                     publishprogress(s);                 } catch (exception e) {                     // todo auto-generated catch block                     log.v("mp3dropboxsync", "onprogresserror");                 }              }         });            }     } catch (dropboxexception e) {         log.v("mp3dropboxsync", "something went wrong while downloading.");         file.delete();     } catch (filenotfoundexception e) {         log.v("mp3dropboxsync", "file not found.");     } catch (exception e) {         log.v("mp3dropboxsync", "unbekannter fehler: "+e.getmessage());     } {         if (out != null) {             try {                 out.close();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }         }         else             dropboxfile[0] = "";     }     return dropboxfile[0]; }  @override protected void onprogressupdate(string... progress) {     super.onprogressupdate(progress);      try {         int percent = integer.parseint(progress[0]);         log.v("mp3dropboxsync","hi progressing - " + percent + "%");          notification.contentview.setprogressbar(r.id.progressbar1, 100, percent, false);         notification.contentview.settextviewtext(r.id.status_text, "downloading... "+datei);          mnotifymanager.notify(10, notification);      } catch (numberformatexception e) {         // todo auto-generated catch block         e.printstacktrace();     }  }  @override protected void onpostexecute(string result) {     // todo auto-generated method stub     super.onpostexecute(result);      log.v("mp3dropboxsync","onpostexecute");      mnotifymanager.cancel(10); }   } 

logcat

08-07 15:14:54.716: i/system.out(29125): waiting debugger settle... 08-07 15:14:54.926: i/system.out(29125): debugger has settled (1366) 08-07 15:14:55.496: d/libegl(29125): loaded /system/lib/egl/libgles_android.so 08-07 15:14:55.527: d/libegl(29125): loaded /system/lib/egl/libegl_adreno200.so 08-07 15:14:55.557: d/libegl(29125): loaded /system/lib/egl/libglesv1_cm_adreno200.so 08-07 15:14:55.567: d/libegl(29125): loaded /system/lib/egl/libglesv2_adreno200.so 08-07 15:14:55.577: v/mp3dropboxsync(29125): onstartcommand 08-07 15:14:55.577: v/mp3dropboxsync(29125): in auth 08-07 15:14:55.577: v/mp3dropboxsync(29125): nach auth - linked: true 08-07 15:14:55.577: v/mp3dropboxsync(29125): dropbox getliste 08-07 15:14:55.677: i/adreno200-eglsub(29125): <configwindowmatch:2078>: format rgba_8888. 08-07 15:14:55.717: d/memalloc(29125): ashmem: mapped buffer base:0x5266b000 size:1536000 fd:63 08-07 15:14:55.727: d/openglrenderer(29125): enabling debug mode 0 08-07 15:14:55.967: i/global(29125): in close() @ sockethttpclientconnection 08-07 15:14:55.987: d/memalloc(29125): ashmem: mapped buffer base:0x52e0c000 size:1536000 fd:67 08-07 15:15:03.464: v/mp3dropboxsync(29125): songdownload 08-07 15:15:03.484: v/mp3dropboxsync(29125): doinbackground 08-07 15:15:03.624: i/global(29125): in close() @ sockethttpclientconnection 08-07 15:15:06.517: v/mp3dropboxsync(29125): onprogress 08-07 15:15:07.108: v/mp3dropboxsync(29125): onprogress 08-07 15:15:07.628: v/mp3dropboxsync(29125): onprogress 08-07 15:15:08.149: v/mp3dropboxsync(29125): onprogress 08-07 15:15:08.659: v/mp3dropboxsync(29125): onprogress 08-07 15:15:09.200: v/mp3dropboxsync(29125): onprogress 08-07 15:15:09.740: v/mp3dropboxsync(29125): onprogress 08-07 15:15:10.261: v/mp3dropboxsync(29125): onprogress 08-07 15:15:10.801: v/mp3dropboxsync(29125): onprogress 08-07 15:15:11.402: v/mp3dropboxsync(29125): onprogress 08-07 15:15:11.943: v/mp3dropboxsync(29125): onprogress 08-07 15:15:12.463: v/mp3dropboxsync(29125): onprogress 08-07 15:15:12.974: v/mp3dropboxsync(29125): onprogress 08-07 15:15:13.494: v/mp3dropboxsync(29125): onprogress 08-07 15:15:14.005: v/mp3dropboxsync(29125): onprogress 08-07 15:15:14.585: v/mp3dropboxsync(29125): onprogress 08-07 15:15:15.146: v/mp3dropboxsync(29125): onprogress 08-07 15:15:15.696: v/mp3dropboxsync(29125): onprogress 08-07 15:15:16.247: v/mp3dropboxsync(29125): onprogress 08-07 15:15:16.847: v/mp3dropboxsync(29125): onprogress 08-07 15:15:17.398: v/mp3dropboxsync(29125): onprogress 08-07 15:15:17.928: v/mp3dropboxsync(29125): onprogress 08-07 15:15:18.439: v/mp3dropboxsync(29125): onprogress 08-07 15:15:19.009: v/mp3dropboxsync(29125): onprogress 08-07 15:15:19.550: v/mp3dropboxsync(29125): onprogress 08-07 15:15:20.090: v/mp3dropboxsync(29125): onprogress 08-07 15:15:20.621: v/mp3dropboxsync(29125): onprogress 08-07 15:15:21.242: v/mp3dropboxsync(29125): onprogress 08-07 15:15:21.742: v/mp3dropboxsync(29125): onprogress 08-07 15:15:22.283: v/mp3dropboxsync(29125): onprogress 08-07 15:15:22.793: v/mp3dropboxsync(29125): onprogress 08-07 15:15:23.304: v/mp3dropboxsync(29125): onprogress 08-07 15:15:23.954: v/mp3dropboxsync(29125): onprogress 08-07 15:15:24.545: v/mp3dropboxsync(29125): onprogress 08-07 15:15:25.075: v/mp3dropboxsync(29125): onprogress 08-07 15:15:25.606: v/mp3dropboxsync(29125): onprogress 08-07 15:15:25.936: i/global(29125): in close() @ sockethttpclientconnection 08-07 15:15:25.936: i/global(29125): call socket close in sockethttpclientconnection, socket=ssl socket on socket[address=/199.47.219.158,port=443,localport=36480] 08-07 15:15:25.976: i/global(29125): i/o error closing connection 08-07 15:15:25.976: i/global(29125): java.net.socketexception: socket closed 08-07 15:15:25.976: i/global(29125):    @ java.net.socket.checkopenandcreate(socket.java:671) 08-07 15:15:25.976: i/global(29125):    @ java.net.socket.getsolinger(socket.java:434) 08-07 15:15:25.976: i/global(29125):    @ org.apache.harmony.xnet.provider.jsse.opensslsocketimplwrapper.getsolinger(opensslsocketimplwrapper.java:156) 08-07 15:15:25.976: i/global(29125):    @ org.apache.http.impl.conn.tsccm.abstractconnpool.closeconnection(abstractconnpool.java:327) 08-07 15:15:25.976: i/global(29125):    @ org.apache.http.impl.conn.tsccm.connpoolbyroute.deleteentry(connpoolbyroute.java:530) 08-07 15:15:25.976: i/global(29125):    @ org.apache.http.impl.conn.tsccm.connpoolbyroute.deleteclosedconnections(connpoolbyroute.java:653) 08-07 15:15:25.976: i/global(29125):    @ org.apache.http.impl.conn.tsccm.threadsafeclientconnmanager.closeexpiredconnections(threadsafeclientconnmanager.java:301) 08-07 15:15:25.976: i/global(29125):    @ com.dropbox.client2.session.abstractsession$idleconnectioncloserthread.run(abstractsession.java:530) 08-07 15:15:25.996: w/idleconnectionhandler(29125): removing connection never existed! 08-07 15:15:26.116: v/mp3dropboxsync(29125): onprogress 08-07 15:15:26.687: v/mp3dropboxsync(29125): onprogress 08-07 15:15:27.197: v/mp3dropboxsync(29125): onprogress 08-07 15:15:27.758: v/mp3dropboxsync(29125): onprogress 08-07 15:15:28.258: v/mp3dropboxsync(29125): onprogress 08-07 15:15:29.019: v/mp3dropboxsync(29125): onprogress 08-07 15:15:29.430: v/mp3dropboxsync(29125): songdownload 08-07 15:15:29.700: v/mp3dropboxsync(29125): doinbackground 08-07 15:15:32.272: v/mp3dropboxsync(29125): onprogress 08-07 15:15:32.773: v/mp3dropboxsync(29125): onprogress 08-07 15:15:33.283: v/mp3dropboxsync(29125): onprogress 08-07 15:15:33.784: v/mp3dropboxsync(29125): onprogress 08-07 15:15:34.304: v/mp3dropboxsync(29125): onprogress 08-07 15:15:34.835: v/mp3dropboxsync(29125): onprogress 08-07 15:15:35.345: v/mp3dropboxsync(29125): onprogress 08-07 15:15:35.866: v/mp3dropboxsync(29125): onprogress 08-07 15:15:36.466: v/mp3dropboxsync(29125): onprogress 08-07 15:15:36.967: v/mp3dropboxsync(29125): onprogress 08-07 15:15:37.487: v/mp3dropboxsync(29125): onprogress 08-07 15:15:38.068: v/mp3dropboxsync(29125): onprogress 08-07 15:15:38.569: v/mp3dropboxsync(29125): onprogress 08-07 15:15:39.079: v/mp3dropboxsync(29125): onprogress 08-07 15:15:39.580: v/mp3dropboxsync(29125): onprogress 08-07 15:15:40.150: v/mp3dropboxsync(29125): onprogress 08-07 15:15:40.751: v/mp3dropboxsync(29125): onprogress 08-07 15:15:41.311: v/mp3dropboxsync(29125): onprogress 08-07 15:15:41.822: v/mp3dropboxsync(29125): onprogress 08-07 15:15:42.402: v/mp3dropboxsync(29125): onprogress 08-07 15:15:42.903: v/mp3dropboxsync(29125): onprogress 08-07 15:15:43.453: v/mp3dropboxsync(29125): onprogress 08-07 15:15:43.954: v/mp3dropboxsync(29125): onprogress 08-07 15:15:44.464: v/mp3dropboxsync(29125): onprogress 08-07 15:15:44.985: v/mp3dropboxsync(29125): onprogress 08-07 15:15:45.485: v/mp3dropboxsync(29125): onprogress 08-07 15:15:45.996: v/mp3dropboxsync(29125): onprogress 08-07 15:15:46.496: v/mp3dropboxsync(29125): onprogress 08-07 15:15:47.007: v/mp3dropboxsync(29125): onprogress 08-07 15:15:47.567: v/mp3dropboxsync(29125): onprogress 08-07 15:15:48.258: v/mp3dropboxsync(29125): onprogress 08-07 15:15:48.839: v/mp3dropboxsync(29125): onprogress 08-07 15:15:49.439: v/mp3dropboxsync(29125): onprogress 08-07 15:15:49.990: v/mp3dropboxsync(29125): onprogress 08-07 15:15:50.210: v/mp3dropboxsync(29125): songdownload 08-07 15:15:50.240: v/mp3dropboxsync(29125): doinbackground //file exist 

i have tried everything. had other effects example onprogressupdate called multiple times after doinbackground finished. @ moment not getting called. cant explain socket close exception. =/

hope can me. have tried remake whole project , reinstalls. didn't work.

thank you!

please try use poc you.

public class mainactivity extends activity { handler handler = new handler();

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     new backgroundtask().execute(""); }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }  class backgroundtask extends asynctask<string, string, string> {      @override     protected string doinbackground(string... params) {         // todo auto-generated method stub          thread t = new thread(new runnable() {              @override             public void run() {                 // todo auto-generated method stub                 (int = 0; < 10; i++) {                     try {                         thread.sleep(1000);                     } catch (interruptedexception e) {                         // todo auto-generated catch block                         e.printstacktrace();                     }                     publishprogress("" + i);                 }             }         });         t.start();          return null;     }      @override     protected void onprogressupdate(string... values) {         // todo auto-generated method stub         super.onprogressupdate(values);         textview textview = (textview) findviewbyid(r.id.textview);         textview.settext("t:" + values[0]);     }      protected void onpostexecute(string result) {         // todo auto-generated method stub         super.onpostexecute(result);      } } 

}


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -