android - Set TextView text from PHP query. Everything works PHP end tested on postman but Textview keeps showing as blank -


i have included android code below. don’t think there wrong php , url have tested these hard-coding url , using postman. seems run ok, textview text not being set when click play button. there no errors showing in logcat either.

below android code:

public class play extends appcompatactivity {      private textview game_id;     private textview team_name;     private textview category;     private button play;     private textview question;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_play);         game_id = (textview) findviewbyid(r.id.playgameid);         game_id.settext(getintent().getstringextra("game_id"));         team_name = (textview) findviewbyid(r.id.playteamname);         team_name.settext(getintent().getstringextra("team_name"));         category = (textview) findviewbyid(r.id.playcategory);         category.settext(getintent().getstringextra("category"));         play = (button) findviewbyid(r.id.buttonplay);         question = (textview) findviewbyid(r.id.tvquestion);          play.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 getquestion();             }         });     }      private void getquestion() {          string url = "http://192.168.0.14/articulate/getquestion.php?category="+category.gettext().tostring() + "&& game_id=" + game_id.gettext().tostring();         stringrequest stringrequest = new stringrequest(url, new response.listener<string>() {             @override             public void onresponse(string response) {                 showjson(response);             }         },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror error) {                         toast.maketext(com.example.conn.articulate.play.this,error.getmessage().tostring(),toast.length_long).show();                     }                 });          requestqueue requestqueue = volley.newrequestqueue(this);         requestqueue.add(stringrequest);     }      private void showjson(string response){         string questionres="";          try {             jsonobject jsonobject = new jsonobject(response);             jsonarray result = jsonobject.getjsonarray("question");             jsonobject collegedata = result.getjsonobject(0);             questionres = collegedata.getstring("question");         } catch (jsonexception e) {             e.printstacktrace();         }         question.settext(questionres);     }  } 

and i’ll include php below although think ok:

if($_server['request_method']=='get') {     //makes work     $category = (string)filter_input(input_get, 'category');     $game_id = $_get['game_id'];      require_once('dbconnect.php');      $query = "select * questions category = '$category' , not exists     (select  *            answered_questions           game_id='.$game_id.'         )order rand() limit 1";      $result = (mysqli_query($con, $query));      $jsondata = array();     while ($array = mysqli_fetch_row($result)) {         $jsondata[] = $array;     }      $data = array(         'question' =>             $jsondata);     echo json_encode( $data);      //close db connection     mysqli_close($con); } 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -