I have developed an android app which uses Yahoo! Weather API
for getting weather information, as Yahoo! Weather API
allows to request the service only 10 to 20
times per hour. my app has tow activities when I switch back and forth between them my app requests the weather service again and again my code for this is :
@Override
protected void onResume() {
// TODO Auto-generated method stub
String nameOfCity= pref.getString("cityname", cityNameInput.getText().toString());
getWeather(null, nameOfCity);// this the AsyncTask which is used to request Yahoo! Weather service.
cityNameInput.setText(nameOfCity);
super.onResume();
Log.d("My_TAG", "in onResume()");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
editor = pref.edit();
if(cityNameInput.getText().toString().equals("")){
cityNameInput.setText(yahooWeatherInfo.getLocationCity());
}else{
editor.putString("cityname", cityNameInput.getText().toString());
}
editor.commit();
super.onPause();
Log.d("MY_TAG", "in onPause()");
}
Now please tell me how to restrict that not to request the Yahoo! Weather Service
again and again on switching between activities.