Sunday 15 May 2011

json - Error with Null -



json - Error with Null -

i working on project here , running issue. working fine before doing sending request url , expecting json response. when check response keeps coming null. not issue before randomly started happening. help appreciate!'

also have class url requests.

this first bit onclick listener on login page. takes text fields , converts them strings. way login works has force info url why set way.

bt.setonclicklistener(new onclicklistener(){ @override public void onclick(view v) { string business relationship = acct.gettext().tostring(); string uname = user.gettext().tostring(); string password = pass.gettext().tostring(); url = ap+"&t2mdeveloperid="+id+account+"&t2musername="+uname+"&t2mpassword="+password; new login().execute(); } } ); }

alright here async task request runs in.

private class login extends asynctask<void, void, void>{ @override protected void onpreexecute(){ super.onpreexecute(); //here display our progress bar. dependent on each page. pdialog = new progressdialog(mainactivity.this); pdialog.setmessage("loading talk2m account"); pdialog.setcancelable(true); pdialog.show(); } @override protected void doinbackground(void... arg0){ //we need create object phone call our service handler create our http request. servicehandler login = new servicehandler(); //now need create request url recieve response. string response = login.makeservicecall(url, servicehandler.get); log.d("response: ", "> " + response); try{ jsonobject jsonobj = new jsonobject(response); string session = jsonobj.getstring(tag_session); }catch(jsonexception e){ e.printstacktrace(); } homecoming null; } @override protected void onpostexecute(void result){ super.onpostexecute(result); if(pdialog.isshowing()) pdialog.dismiss(); } }

if json you're getting null, first guess verify hitting right url. if case, there may issue on api side. may want test http request outside of context of application, in rest client or web browser.

regards.

json android-asynctask null return webresponse

No comments:

Post a Comment