android - Asynctask never dies -
i use asynctask
show data json asynctask show loading never dies, no error loading , loading code doinbackground
function
@override protected void onpreexecute() { progressdialog.show(); } @override protected integer doinbackground(string... arg0) { // check login response // creating json parser instance jsonparser jparser = new jsonparser(); //databasehandler db = new databasehandler( // activity.getapplicationcontext()); // getting json string url jsonobject json = jparser.getjsonfromurl(url+id_user); try { if (json.getstring(key_success) != null) { string res = json.getstring(key_success); if(integer.parseint(res) == 1){ // getting array of following user = json.getjsonarray(key_user); // looping through following (int = 0; < user.length(); i++) { jsonobject c = user.getjsonobject(i); // storing each json item in variable nama = c.getstring(key_nama); instansi = c.getstring(key_instansi); status = c.getstring(key_status); responsecode = 1; } } else{ responsecode = 0; } } } catch (nullpointerexception e) { e.printstacktrace(); } catch (jsonexception e) { e.printstacktrace(); } return responsecode; } @override protected void onpostexecute(integer responsecode) { if (responsecode == 1) { headernama = (textview)activity.findviewbyid(r.id.headernama); headerinstansi = (textview)activity.findviewbyid(r.id.headerinstansi); buttonstatus = (button)activity.findviewbyid(r.id.buttonstatus); headernama.settext(nama); headerinstansi.settext(instansi); buttonstatus.settext(status); }else { progressdialog.dismiss(); activity.showdashboarderror(responsecode); } }
i think no probleme in doinbackground, please thanks
you should dismiss
dialog
like:
if (progressdialog.isshowing()) { progressdialog.dismiss(); }
Comments
Post a Comment