how to convert the output of a PHP into a string to be used in Android?

Wednesday, November 4, 2015

I have a .php file on the server side that works fine and extracts me results with PDO method. Therefore, when I click the file on the browser, I have no problem.



Yet, I would like this output to be put in a textView in my Android app.



Now, by the end of the php file i added:



print(json_encode(array($output)));


while in MainActivity.class I tried to get this output by parsing it through JSON.



try {
String s = "";
JSONArray jArray = new JSONArray(result);

for(int i=0; i<jArray.length();i++){
JSONObject json = jArray.getJSONObject(i);

}

TextView.setText(s);


Now, how do I end the JSONObject, so that "s" becomes a String that can later be added to the TextView?



Thanks in advance

0 comments:

Post a Comment