안녕하세요
안드로이드 시작한 초보입니다 다름이 아니라
구글 날씨 해보는데 결과가 안뜨네요ㅠㅠ
package exam.weather;
import java.io.InputStream;
import java.net.URL;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import android.widget.TextView;
public class Weather_xmlActivity extends Activity{
/** Called when the activity is first created. */
//ArrayList<ForecastItem> list;
TextView desc; //오늘 날짜
TextView temp; //오늘 기온
TextView wind;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
desc = (TextView)findViewById(R.id.desc);
temp = (TextView)findViewById(R.id.temp);
wind = (TextView)findViewById(R.id.wind);
WeatherItem item = new WeatherItem();
try
{
String url = "http://www.google.co.kr/ig/api?weather=Ulsan";
URL u = new URL("url);
InputStream in= u.openStream();
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(in, "EUC-KR");
while (xpp.getEventType() != XmlPullParser.END_DOCUMENT)
{
if (xpp.getEventType() == XmlPullParser.START_TAG)
{
if (xpp.getName().equals("forecast_date"))
{
item.date = xpp.getAttributeValue(0);
desc.setText("오늘날짜: " + item.date);
}
if (xpp.getName().equals("temp_c"))
{
item.temp = xpp.getAttributeValue(0);
temp.setText("오늘기온: " + item.temp);
}
if (xpp.getName().equals("wind_condition"))
{
item.wind = xpp.getAttributeValue(0);
wind.setText("오늘바람: " + item.wind);
}
if (xpp.getName().equals("problem_cause"))
{
Toast.makeText(this, "해당지역의 날씨정보를 이용할 수 없습니다", 0).show();
desc.setText("해당지역의 날씨정보를 이용할 수 없습니다.");
temp.setText("해당지역의 날씨정보를 이용할 수 없습니다.");
wind.setText("해당지역의 날씨정보를 이용할 수 없습니다.");
}
}
xpp.next();
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
왜그럴까요?ㅠㅠ




흠...혹시 에뮬레이터에서 테스트하시나요?