Android stdio を使って位置情報を取得し気温などを表示したいと考えています
。
ビルドするとCompilation failed; see the compiler error output for details.
初心者で色々調べてみたのですがわからなかったのでお願いします。
OnClickListener link_Listener = new OnClickListener() {
public void onClick(View v) {
Uri uri = Uri.parse("http://openweathermap.org/");
Intent i = new Intent(Intent.ACTION_VIEW,uri);
startActivity(i);
}
};
OnClickListener map_Listener = new OnClickListener() {
public void onClick(View v) {
TextView data1 = (TextView)findViewById(2000);
TextView data2 = (TextView)findViewById(4000);
Uri uri = Uri.parse("http://maps.google.com/maps?q=" + data1.getText().toString() + "," + data2.getText().toString());
Intent i = new Intent(Intent.ACTION_VIEW,uri);
startActivity(i);
}
};
// 緯度の取得
double latitude = location.getLatitude();
// 経度の取得
double longitude = location.getLongitude();
String requestURL = "http://api.openweathermap.org/data/2.5/weather?lat=" + String.valueOf(latitude) + "&lon=" + String.valueOf(longitude) + "&mode=xml";
URL url;
try {
url = new URL(requestURL);
InputStream is = url.openConnection().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuilder sb = new StringBuilder();
String line;
while (null != (line = reader.readLine())) {
sb.append(line.replace(BR, ""));
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}