获取天气对我的当前位置,机器人我的、当前位置、机器人、天气

由网友(、用笑容改变世界。)分享简介:我想打一个Android应用程序从该网站使用openweathermap我天气预报得到的,我看到的网址是这样写的:I want to make an android application to get weather forecast using openweathermap I from the website,...

我想打一个Android应用程序从该网站使用openweathermap我天气预报得到的,我看到的网址是这样写的:

I want to make an android application to get weather forecast using openweathermap I from the website, I see that the URL is written like this :

[api.openweathermap.org/data/2.5/forecast/daily?lat=35&lon=139&cnt=10&mode=json]

[api.openweathermap.org/data/2.5/forecast/daily?lat=35&lon=139&cnt=10&mode=json]

我想补充我的当前位置的经度和纬度,而不是常量;我得到的经度和我的当前位置的纬度;但我不知道如何将它们添加到URL。

I want to add my current location as longitude and latitude instead of constant values; I got the longitude and latitude of my current location; but I don't know how to add them into the URL.

我可以使用VAL [经度] + VAL [纬度] ??

can I use val[longitude]+val[latitude]??

推荐答案

假设经度和纬度双打像的这个。

Assuming the latitude and longitude are doubles for coordinates like this.

您会写:

double lat, lon;
...
String newURL = "api.openweathermap.org/data/2.5/forecast/daily?lat=" + lat + "&lon=" + lon + "&cnt=10&mode=json";

话虽这么说,这是一个非常基本的问题。我建议你​​在

That being said, this is a very basic question. I'd recommend you do the following java tutorials at

http://javala.cs.tut.fi

的该系统能够档次你我建议你尝试获得至少90%的点就可以了。的

您可以尝试使用 org.apache.http 库亚瑟的建议,但我怕你可能无法得到远,如果你还没有记忆的简单Java构造呢。

You could try using the org.apache.http library as suggested by Arthur, but I'm afraid you might not get far if you haven't memorized the simpler Java constructs yet.

阅读全文

相关推荐

最新文章