获取天气对我的当前位置,机器人 [英] getting the weather for my current location, android

查看:159
本文介绍了获取天气对我的当前位置,机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个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.

这篇关于获取天气对我的当前位置,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆