php - display result of json data in textview of android -
i having 1 problem while displaying data in android app.this php.i have edited shorten code.
if($imei_no!="" && $app_auid!="") { //chk query $chk_query=$db1->query("select * user imei_number='$imei_no'"); $chk_cnt=$chk_query->rowcount(); if($chk_cnt>0) { $search_qry=$db1->query("select * candidate_reception cr,candidate_counseling cc ,candidate_admission ca cr.candidate_id=cc.candidate_id , cr.candidate_id=ca.candidate_id , cr.auid=ca.auid , cr.counseling_id=cc.counseling_id , cr.auid='$app_auid'"); $ser_count=$search_qry->rowcount(); if($ser_count>0) { $stud_row=$search_qry->fetch(pdo::fetch_obj); $candidate_id=$stud_row->candidate_id; $auid = $stud_row->auid; $usn_no = $stud_row->usn_no; $sx = $stud_row->candidate_sex //image path if($inst_id==1){ $img_path = "1"; } if($inst_id==2){ $img_path = "2"; } $result=array(); array_push($result, array('name' => $candidate_name,'img_path'=>$img_path)); echo json_encode(array("can_data"=>$result)); echo "success" } else { echo "auid not found."; } } else { echo "invalid imei number.!!!"; } } ?>
and java code:
private static final string login_url = "http://xxx.xxx.x.x/mobile_app/data_push.php"; private edittext edittextusername; private button buttonlogin; telephonymanager tel; textview imei; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_imei__val); edittextusername = (edittext) findviewbyid(r.id.edittextauid); buttonlogin = (button) findviewbyid(r.id.btn); buttonlogin.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { login(); } }); tel = (telephonymanager) getsystemservice(context.telephony_service); imei = (textview) findviewbyid(r.id.textview2); imei.settext(tel.getdeviceid().tostring()); } private void login(){ string username = edittextusername.gettext().tostring().trim(); string imei_no = imei.gettext().tostring().trim(); userlogin(username,imei_no); } private void userlogin(final string username,final string imei_no){ class userloginclass extends asynctask<string,void,string> { progressdialog loading; @override protected void onpreexecute() { super.onpreexecute(); loading = progressdialog.show(imei_val.this,"please wait",null,true,true); } @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); if(s=="success"){ intent intent = new intent(imei_val.this, capturephoto.class); // intent.putextra(user_name,username); startactivity(intent); } else{ toast.maketext(imei_val.this, s, toast.length_long).show(); log.d("tag name", "log message"); } } @override protected string doinbackground(string... params) { hashmap<string,string> data = new hashmap<>(); data.put("auid",params[0]); data.put("imei",params[1]); registeruserclass ruc = new registeruserclass(); string result = ruc.sendpostrequest(login_url,data); return result; } } userloginclass ulc = new userloginclass(); ulc.execute(username,imei_no); } }
my problem when clicking on login button, getting json result in toast student details after valid user inputs.i want goto next activity if the user inputs valid , display other details name,college etc.how can that? here getting json result response when enter valid inputs.i not go next activity , display other details in text box though entering correct regno.
@user6588225
so sending json success message
so rather using ==
try use contains
so inside onpostexecute(string s)
@override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); if(s.contains("success")){ intent intent = new intent(imei_val.this, capturephoto.class); // intent.putextra(user_name,username); startactivity(intent); } else{ toast.maketext(imei_val.this, s, toast.length_long).show(); log.d("tag name", "log message"); } }
Comments
Post a Comment