Android Open Source - Android_Sunshine_Tutorial Weather Data Parser






From Project

Back to project page Android_Sunshine_Tutorial.

License

The source code is released under:

GNU General Public License

If you think the Android project Android_Sunshine_Tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.androidtutorialsunshine;
/* w w  w.j ava 2s . com*/
import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

//Passing in a string form of the JSON returned by the api call
public class WeatherDataParser {

  public static double getMaxTemperatureForDay(String weatherJSONString, int dayInfo) throws JSONException{
    
    JSONObject weather = new JSONObject (weatherJSONString);
    JSONArray days = weather.getJSONArray("list");
    //JSONObject dayInfo = days.getJSONObject(dayIndex);
    //JSONObject temperatureInfo = dayInfo.getJSONObject("temp");
    
    //return temperatureInfo.getDouble("max");
    
    return 2.0;
  }
  
}




Java Source Code List

com.example.androidtutorialsunshine.ForecastFragment.java
com.example.androidtutorialsunshine.MainActivity8.java
com.example.androidtutorialsunshine.SettingsActivity.java
com.example.androidtutorialsunshine.WeatherDataParser.java
com.pgmacdesign.androidtutorialsunshine.ApplicationTest.java
com.pgmacdesign.androidtutorialsunshine.MainActivity6.java