Asp.Net services doesn't return response message when I request more than 4 times in android -
i making android application , parsing data asp.net services , when call service more 4 times doesn't return response, didn't data , after waiting 10 minutes services working , can data it. trying 2 weeks , didn't solve it. please me.. code below
public class sonrakiactivity extends activity { bundle get_data; int bas_i; textview txt, text2; // button secretbtn; string type; int typeid; int grpid; int id; int sorusayisi = 0; int cevaplanan = 0; boolean hata = false; int akis_soru_sorusayisi = 0; string last_type_inmethod; bundle data_gonder; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.sonraki_olay); txt = (textview) findviewbyid(r.id.textview1); get_data = getintent().getextras(); bas_i = get_data.getint("data_sonraki_soru_id"); data_gonder = new bundle(); gonder(); } public void gonder() { try { new thread(new runnable() { @override public void run() { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/question"); httppost.setheader("content-type", "application/json"); httppost.setheader("accept", "application/json"); jsonobject jsonparameter = new jsonobject(); final globalclass globalvariable_soru = (globalclass) getapplicationcontext(); try { int type_id = akis_typeid(); int grp_id = akis_grpid(); log.i("akis_typeid()", "" + type_id); log.i("akis_grpid()", "" + grp_id); jsonparameter.put("id", type_id); jsonparameter.put("grpid", grp_id); httppost.setentity(new stringentity(jsonparameter .tostring(), "utf-8")); log.i("httppost", "" + httppost); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); string responsetext = entityutils.tostring(entity); log.i("@responcequestion_soru", "" + responsetext); try { jsonobject returndata = new jsonobject(responsetext); jsonarray jsonmainnode = returndata .optjsonarray("d"); int lengthjsonarr = jsonmainnode.length(); log.i("@lengthjsonquestion_soru", "" + lengthjsonarr); sorusayisi = lengthjsonarr; // quetion_id final int question_id = akis_typeid(); log.i("question_id_soru", "" + question_id); (int = 0; < sorusayisi; i++) { if (i == sorusayisi) break; jsonobject jsonchildnode = jsonmainnode .getjsonobject(i); try { final string text = jsonchildnode .optstring("text"); globalvariable_soru.setsorumuz(text); log.i("log_banner_text", "" + text); final int cevap_id = jsonchildnode .optint("cevapid"); final list<string> answer = cevaplar(cevap_id); log.i("answers", "" + answer); log.i("log_banner_id", "" + cevap_id); final int cevap_sayisi = jsonchildnode .optint("cevapsayisi"); log.i("log_cevap_sayisi", "" + cevap_sayisi); if (i == 0) { txt.post(new runnable() { @override public void run() { try { final relativelayout lm = (relativelayout) findviewbyid(r.id.genellayout); txt.settext(text); if (cevap_sayisi == 2) { button btn1 = new button( getapplicationcontext()); btn1.setbackgroundresource(r.drawable.stylebutton_iyi); btn1.settext(answer .get(0)); btn1.settextsize(30); btn1.settextcolor(color.black); btn1.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(1, question_id); } }); button btn2 = new button( getapplicationcontext()); btn2.setbackgroundresource(r.drawable.stylebutton_orta); btn2.settext(answer .get(1)); btn2.settextsize(30); btn2.settextcolor(color.black); btn2.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(2, question_id); } }); linearlayout ll = (linearlayout) findviewbyid(r.id.buttonlayout); ll.setorientation(linearlayout.vertical); layoutparams lp = new layoutparams( new layoutparams( 300, 100)); ll.addview(btn1, lp); ll.addview(btn2, lp); lm.addview(ll); } if (cevap_sayisi == 3) { button btn1 = new button( getapplicationcontext()); btn1.settext(answer .get(0)); btn1.setbackgroundresource(r.drawable.stylebutton_iyi); btn1.settextsize(30); btn1.settextcolor(color.black); btn1.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(1, question_id); // intent inm = // new // intent(getapplicationcontext(),bitismesage.class); // startactivity(inm); } }); button btn2 = new button( getapplicationcontext()); btn2.settext(answer .get(1)); btn2.setbackgroundresource(r.drawable.stylebutton_orta); btn2.settextsize(30); btn2.settextcolor(color.black); btn2.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(2, question_id); } }); button btn3 = new button( getapplicationcontext()); btn3.settext(answer .get(2)); btn3.setbackgroundresource(r.drawable.stylebutton_kotu); btn3.settextsize(30); btn3.settextcolor(color.black); btn3.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(3, question_id); } }); linearlayout ll = (linearlayout) findviewbyid(r.id.buttonlayout); ll.setorientation(linearlayout.vertical); layoutparams lp = new layoutparams( new layoutparams( 300, 100)); ll.addview(btn1, lp); ll.addview(btn2, lp); ll.addview(btn3, lp); lm.addview(ll); } if (cevap_sayisi == 4) { button btn1 = new button( getapplicationcontext()); btn1.settext(answer .get(0)); btn1.setbackgroundresource(r.drawable.stylebutton_iyi); btn1.settextsize(30); btn1.settextcolor(color.black); btn1.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(1, question_id); } }); button btn2 = new button( getapplicationcontext()); btn2.settext(answer .get(1)); btn2.setbackgroundresource(r.drawable.stylebutton_orta); btn2.settextsize(30); btn2.settextcolor(color.black); btn2.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(2, question_id); } }); button btn3 = new button( getapplicationcontext()); btn3.settext(answer .get(2)); btn3.setbackgroundresource(r.drawable.stylebutton_kotu); btn3.settextsize(30); btn3.settextcolor(color.black); btn3.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(3, question_id); } }); button btn4 = new button( getapplicationcontext()); btn4.settext(answer .get(3)); btn4.setbackgroundresource(r.drawable.stylebutton_fena); btn4.settextsize(30); btn4.settextcolor(color.black); btn4.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(4, question_id); } }); linearlayout ll = (linearlayout) findviewbyid(r.id.buttonlayout); ll.setorientation(linearlayout.vertical); layoutparams lp = new layoutparams( new layoutparams( 300, 100)); ll.addview(btn1, lp); ll.addview(btn2, lp); ll.addview(btn3, lp); ll.addview(btn4, lp); lm.addview(ll); } if (cevap_sayisi == 5) { button btn1 = new button( getapplicationcontext()); btn1.settext(answer .get(0)); btn1.setbackgroundresource(r.drawable.stylebutton_iyi); btn1.settextsize(30); btn1.settextcolor(color.black); btn1.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(1, question_id); } }); button btn2 = new button( getapplicationcontext()); btn2.settext(answer .get(1)); btn2.setbackgroundresource(r.drawable.stylebutton_orta); btn2.settextsize(30); btn2.settextcolor(color.black); btn2.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(2, question_id); } }); button btn3 = new button( getapplicationcontext()); btn3.settext(answer .get(2)); btn3.setbackgroundresource(r.drawable.stylebutton_kotu); btn3.settextsize(30); btn3.settextcolor(color.black); btn3.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(3, question_id); } }); button btn4 = new button( getapplicationcontext()); btn4.settext(answer .get(3)); btn4.setbackgroundresource(r.drawable.stylebutton_fena); btn4.settextsize(30); btn4.settextcolor(color.black); btn4.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(4, question_id); } }); button btn5 = new button( getapplicationcontext()); btn5.settext(answer .get(4)); btn5.setbackgroundresource(r.drawable.stylebutton_cokiyi); btn5.settextsize(30); btn5.settextcolor(color.black); btn5.setonclicklistener(new onclicklistener() { @override public void onclick( view v) { // todo // auto-generated // method stub cevapla(5, question_id); } }); linearlayout ll = (linearlayout) findviewbyid(r.id.buttonlayout); ll.setorientation(linearlayout.vertical); layoutparams lp = new layoutparams( new layoutparams( 300, 100)); ll.addview(btn1, lp); ll.addview(btn2, lp); ll.addview(btn3, lp); ll.addview(btn4, lp); ll.addview(btn5, lp); lm.addview(ll); } } catch (exception e) { e.printstacktrace(); } } }); } } catch (exception e) { onceki_soru(); } } } catch (jsonexception e) { onceki_soru(); } } catch (exception e) { runonuithread(new runnable() { @override public void run() { toast.maketext(getapplicationcontext(), "İnternet ayarlarınızı kontrol ediniz", toast.length_short).show(); } }); onceki_soru(); e.printstacktrace(); } } }).start(); } catch (exception e) { e.printstacktrace(); } } private list<string> cevaplar(int cevabim_id) { list<string> getcevap = new arraylist<string>(); try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/answers"); httppost.setheader("content-type", "application/json"); httppost.setheader("accept", "application/json"); jsonobject jsonparameter = new jsonobject(); jsonparameter.put("id", cevabim_id); httppost.setentity(new stringentity(jsonparameter.tostring(), "utf-8")); log.i("httppost", "" + httppost); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); string responsetext = entityutils.tostring(entity); log.i("@responceanswers", "" + responsetext); try { jsonobject returndata = new jsonobject(responsetext); jsonarray jsonmainnode = returndata.optjsonarray("d"); int lengthjsonarr = jsonmainnode.length(); log.i("@lengthjsonanswer", "" + lengthjsonarr); sorusayisi = lengthjsonarr; (int = 0; < sorusayisi; i++) { if (i == sorusayisi) break; jsonobject jsonchildnode = jsonmainnode.getjsonobject(i); try { final string value1 = jsonchildnode.optstring("value1"); final string value2 = jsonchildnode.optstring("value2"); final string value3 = jsonchildnode.optstring("value3"); final string value4 = jsonchildnode.optstring("value4"); final string value5 = jsonchildnode.optstring("value5"); getcevap.add(value1); getcevap.add(value2); getcevap.add(value3); getcevap.add(value4); getcevap.add(value5); } catch (exception e) { // todo: handle exception } } } catch (exception e) { // todo: handle exception } } catch (exception e) { // todo: handle exception runonuithread(new runnable() { @override public void run() { toast.maketext(getapplicationcontext(), "İnternet ayarlarınızı kontrol ediniz", toast.length_short).show(); } }); } return getcevap; // todo auto-generated method stub } private int akis_typeid() { try { jsonobject returndata = null; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/akis"); httppost.setheader("content-type", "application/json"); jsonobject jsonparameter = new jsonobject(); final textview textview1 = (textview) findviewbyid(r.id.txt1); try { httppost.setentity(new stringentity(jsonparameter.tostring(), "utf-8")); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); string responsestring = entityutils.tostring(entity); log.i("@akis_responsestring", "" + responsestring); try { returndata = new jsonobject(responsestring); jsonarray jsonmainnode = returndata.optjsonarray("d"); int lengthjsonarr = jsonmainnode.length(); akis_soru_sorusayisi = lengthjsonarr; log.i("log_jsonlength", "" + akis_soru_sorusayisi); (; bas_i < akis_soru_sorusayisi; bas_i++) { jsonobject jsonchildnode = jsonmainnode .getjsonobject(bas_i); try { type = jsonchildnode.optstring("type").tostring(); log.i("@log_type", "" + type); if (type.equals("soru")) { id = jsonchildnode.optint("id"); log.i("@log_id", "" + id); grpid = jsonchildnode.optint("grpid"); log.i("@log_grpid", "" + grpid); typeid = jsonchildnode.optint("typeid"); log.i("@log_typeid", "" + typeid); break; } } catch (exception e) { log.i("errormessage", "" + e.getmessage()); } } } catch (jsonexception e) { } } catch (exception e) { } } catch (exception e) { e.printstacktrace(); } return typeid; } private void cevapla(int i, int question_id) { // todo auto-generated method stub try { thread.sleep(1500); oyla(i, question_id); // sonrakisorukontrol(); gettype(); } catch (exception e) { // todo: handle exception e.printstacktrace(); } } private void gettype() { // todo auto-generated method stub try { new thread(new runnable() { @override public void run() { jsonobject returndata = null; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/akis"); httppost.setheader("content-type", "application/json"); jsonobject jsonparameter = new jsonobject(); try { httppost.setentity(new stringentity(jsonparameter .tostring(), "utf-8")); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); string responsestring = entityutils.tostring(entity); log.i("@akis_responsestring_soru_akiss", "" + responsestring); try { int inc_bas_i = bas_i + 1; log.i("inc_sonraki_soru_id", "" + inc_bas_i); returndata = new jsonobject(responsestring); jsonarray jsonmainnode = returndata .optjsonarray("d"); int lengthjsonarr = jsonmainnode.length(); int sorusayisi = lengthjsonarr; log.i("log_jsonlength_soru_akis", "" + sorusayisi); (; inc_bas_i < sorusayisi; inc_bas_i++) { jsonobject jsonchildnode = jsonmainnode .getjsonobject(inc_bas_i); try { last_type_inmethod = jsonchildnode .optstring("type").tostring(); log.i("@log_type_soru_akis", "" + type); if (last_type_inmethod.equals("soru")) { intent pass_other_activty = new intent( getapplicationcontext(), sonrakiactivity.class); data_gonder.putint( "data_sonraki_soru_id", inc_bas_i); pass_other_activty .putextras(data_gonder); startactivity(pass_other_activty); break; } if (last_type_inmethod.equals("bitis")) { intent pass_other_activty = new intent( getapplicationcontext(), bitismesage.class); startactivity(pass_other_activty); break; } if (last_type_inmethod .equals("kullanıcı girisi")) { intent pass_other_activty = new intent( getapplicationcontext(), kullanicigirisi1.class); data_gonder.putint( "data_sonraki_soru_id", inc_bas_i); pass_other_activty .putextras(data_gonder); startactivity(pass_other_activty); // break; } } catch (exception e) { log.i("errormessage", "" + e.getmessage()); } } } catch (jsonexception e) { runonuithread(new runnable() { @override public void run() { toast.maketext( getapplicationcontext(), "İnternet ayarlarınızı kontrol ediniz", toast.length_short).show(); } }); } } catch (exception e) { runonuithread(new runnable() { @override public void run() { toast.maketext(getapplicationcontext(), "İnternet ayarlarınızı kontrol ediniz", toast.length_short).show(); } }); } } }).start(); } catch (exception e) { e.printstacktrace(); } } private void oyla(final int cevabim_id, final int questionn_id) { // todo auto-generated method stub try { new thread(new runnable() { @override public void run() { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/oyla"); httppost.setheader("content-type", "application/json"); httppost.setheader("accept", "application/json"); jsonobject jsonparameter = new jsonobject(); try { log.i("question_iddd", "" + questionn_id); log.i("question_iddd", "" + cevabim_id); jsonparameter.put("id", questionn_id); jsonparameter.put("cevapid", cevabim_id); try { telephonymanager telephonymanager = (telephonymanager) getsystemservice(context.telephony_service); string deviceid = telephonymanager.getdeviceid(); jsonparameter.put("imei", deviceid); } catch (exception e) { jsonparameter.put("imei", "imei yok"); } httppost.setentity(new stringentity(jsonparameter .tostring(), "utf-8")); httpclient.execute(httppost); } catch (exception e) { runonuithread(new runnable() { @override public void run() { toast.maketext(getapplicationcontext(), "İnternet ayarlarınızı kontrol ediniz", toast.length_short).show(); } }); e.printstacktrace(); } } }).start(); } catch (exception e) { e.printstacktrace(); } } private int akis_grpid() { try { jsonobject returndata = null; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost( "http://78.186.62.169:8210/anketservis.asmx/akis"); httppost.setheader("content-type", "application/json"); jsonobject jsonparameter = new jsonobject(); final textview textview1 = (textview) findviewbyid(r.id.txt1); try { // jsonparameter.put("anketid", "3"); httppost.setentity(new stringentity(jsonparameter.tostring(), "utf-8")); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); string responsestring = entityutils.tostring(entity); log.i("@akis_responsestring", "" + responsestring); try { returndata = new jsonobject(responsestring); jsonarray jsonmainnode = returndata.optjsonarray("d"); int lengthjsonarr = jsonmainnode.length(); sorusayisi = lengthjsonarr; log.i("log_jsonlength", "" + sorusayisi); (; bas_i < sorusayisi; bas_i++) { // if (i == sorusayisi) // break; jsonobject jsonchildnode = jsonmainnode .getjsonobject(bas_i); try { type = jsonchildnode.optstring("type").tostring(); log.i("@log_type", "" + type); if (type.equals("soru")) { id = jsonchildnode.optint("id"); log.i("@log_id", "" + id); grpid = jsonchildnode.optint("grpid"); log.i("@log_grpid", "" + grpid); typeid = jsonchildnode.optint("typeid"); log.i("@log_typeid", "" + typeid); break; } } catch (exception e) { log.i("errormessage", "" + e.getmessage()); } } } catch (jsonexception e) { } } catch (exception e) { } } catch (exception e) { e.printstacktrace(); } return grpid; } public void onceki_soru() { try { final globalclass globalvariable = (globalclass) getapplicationcontext(); final textview txt_soru = (textview) findviewbyid(r.id.textview1); // final textview textviewhdn1 = (textview) // findviewbyid(r.id.txthdn1); txt_soru.post(new runnable() { @override public void run() { try { txt_soru.settext(globalvariable.getsorumuz()); } catch (exception e) { e.printstacktrace(); } } }); } catch (exception e) { e.printstacktrace(); } }
Comments
Post a Comment