I am using AsyncTask to call yahooweather API. Following is the code:
public class myactivity extends Activity {
final String yahooapisBase = \"http:
you are calling
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG)
.show();
in QueryYahooWeather
which is being called in doInBackground
.
You can not call UI
calls from background thread.
Remove all Toast's from QueryYahooWeather
method because this method is called from doInBackground(Object... params)
of AsyncTask
and you can not Access Ui elements like Toast(also an Ui element)from background Thread.
NOTE : if you want to known what's going on in background then use Log instead of Toast's
EDIT:
Change doInBackground as :
@Override
protected String doInBackground(Object... params) {
// TODO Auto-generated method stub
String strresult="";
try {
Log.i("my label", "entering in doInBackground");
Log.i("params[0]", params[0].toString());
strresult= QueryYahooWeather(params[0].toString());
Log.i("strresult result ::: ", strresult);
} catch (Exception e) {
Log.i("my label", e.toString());
return null;
}
return strresult;
}