android - onProgressUpdate in Async is not being called -
im having problems progressdialog and(for now) stops when async threads onprogressupdate() never gets called. onpreexecute() , doinbackground() runs fine, cannot life of me onprogressupdate() function start :( code taken her: http://developer.android.com/reference/android/os/asynctask.html
and here version of code:
private class createpasswordlist2 extends asynctask<string, integer, long> { @override protected void onpreexecute() { super.onpreexecute(); log.v(logtag,"in async: onpreexecute..."); //progressdialog progressdialog = progressdialog.show(mainactivity.this, "wait", "downloading..."); //pdialog = new progressdialog(context); pdialog = new progressdialog(mainactivity.this); pdialog.setmessage("decrypting, please wait..."); pdialog.setindeterminate(false); pdialog.setmax(100); pdialog.setprogressstyle(progressdialog.style_horizontal); pdialog.setcancelable(true); pdialog.show(); } @override protected long doinbackground(string... foo) { int count =20; long totalsize = 0; (int = 0; < count; i++) { try{ thread.sleep(1000); }catch(exception e) { log.v(logtag, e.getmessage()); } totalsize +=1; log.v(logtag,"async2...doinbackground"); publishprogress((int) ((i / (float) count) * 100)); // escape if cancel() called if (iscancelled()) break; } return totalsize; } @override protected void onprogressupdate(integer... progress) { string logtag=""; log.v(logtag,"async2...onprogressupdate"); pdialog.setprogress(progress[0]); } @override protected void onpostexecute(long result) { log.v(logtag,"async2...onpostexecute"); pdialog.dismiss(); // showdialog("downloaded " + result + " bytes"); } }
the program executes doinbackground() function , prints log lines, screen on phone turns black , never changes. ive search entire (i sure...) internet people problem, none of proposed solutions seems work.
any , appriciated
kenneth
Comments
Post a Comment