I have written a Weather class that gets weather information from an online API. The Weather class uses a callback so when weather information gets returned from the API the calling Activity will be notified of available weather data. This all works great the first time. Then after closing the activity and going to another one, and then returning to the previous activity the TextViews do not get updated.
public class ForecastActivity extends ActionBarActivity implements OnWeatherAvailable { SolunarWorkflow solunarWorkflow;LocationClient mLocationClient;private Solunar solunar;private Calendar rightNow;private TextView txtTemp;private TextView txtWindSpeed;private TextView txtWindDirection;private TextView txtHumidity;private TextView txtPressure;private static float temperature;private static float windSpeed;private static String windDirection;private static float humidity;private static float pressure; @Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.forecast_layout); txtTemp = (TextView) findViewById(R.id.txtTemperature); txtWindSpeed = (TextView) findViewById(R.id.txtWindSpeed); txtWindDirection = (TextView) findViewById(R.id.txtWindDirection); txtHumidity = (TextView) findViewById(R.id.txtHumidityLabel); txtPressure = (TextView) findViewById(R.id.txtPressure);} @Overrideprotected void onResume() { super.onResume(); Weather.getInstance(this).sendWeatherRequest(this, (float) AndroidLocation.getLat(), (float) AndroidLocation.getLon()); populateSolunarData();} @Overridepublic void weatherAvailable(final WeatherData weatherData) { temperature = weatherData.getData().getCurrent_condition().get(0).getTemp_F(); windSpeed = weatherData.getData().getCurrent_condition().get(0).getWindspeedMiles(); windDirection = weatherData.getData().getCurrent_condition().get(0).getWinddir16Point(); humidity = weatherData.getData().getCurrent_condition().get(0).getHumidity(); pressure = weatherData.getData().getCurrent_condition().get(0).getPressure(); Handler textViewHandler = new Handler(); // runnable to allow updating the UI from the thread Runnable updateTextView = new Runnable() { public void run() { txtTemp.setText("" + temperature); txtWindSpeed.setText("" + windSpeed); txtWindDirection.setText(windDirection); txtHumidity.setText("" + humidity); txtPressure.setText("" + pressure); } }; textViewHandler.post(updateTextView); } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.