CelestialCreator CelestialCreator - 1 year ago 67
JSON Question

How so I return multiple JSON values to multiple text views?

I did research for

. But only found tutorials for
, not how to make allow multiple text views for a
. Should I have another method, add parameters or what?

This is my

"name": "iss",
"id": 25544,
"latitude": -16.621580566205,
"longitude": -22.573425077475,
"altitude": 403.33965999684,
"velocity": 27615.932538565,
"visibility": "daylight",
"footprint": 4421.7128198729,
"timestamp": 1478617317,
"daynum": 2457701.1263542,
"solar_lat": -16.808913358406,
"solar_lon": 310.46294067763,
"units": "kilometers"

Here is the code if you want to see it,

public class IsstatusActivity extends AppCompatActivity {
String longitSt;
JSONParser jsonparser = new JSONParser();
TextView latitude;
TextView longitude;
String lat;
String longit;
JSONObject jobj = null;

protected void onCreate(Bundle savedInstanceState) {
latitude = (TextView) findViewById(R.id.Coordinates);

new retrievedata().execute();

class retrievedata extends AsyncTask<String, String, String> {

public String doInBackground(String... args) {
jobj = jsonparser.makeHttpRequest("http://api.wheretheiss.at/v1/satellites/25544");
try {
lat = "latitude: " + jobj.getString("latitude");
longit = "longitude :" + jobj.getString("longitude");
} catch (JSONException e) {
// TODO Auto-generated catch block
return lat;

protected void onPostExecute(String lat) {

Answer Source

You are doing it wrong
In onPostExecute() instead of longit.setText(longitude) use longitude.setText(longit) as longitude is a TextView reference and longit is a String.It goes like this
1. Use String lat and long as global variables.
2. After making network call set lat and long values.
3. In onPostExecute setText for your textviews.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download