所以我已经实施了大约一年的谷歌地图 V2,没有问题。但是,在我从开放地图实施天气服务后,授权似乎失败了。任何帮助将不胜感激!这是一个需要开放天气的类。我想知道来自这里的 http 调用是否会干扰 G.Maps 发送授权请求。
public class RemoteFetch {
private static final String OPEN_WEATHER_MAP_API =
"http://api.openweathermap.org/data/2.5/weather?q=%s&units=metric";
public static JSONObject getJSON(Context context, String city){
try {
URL url = new URL(String.format(OPEN_WEATHER_MAP_API, city));
HttpURLConnection connection =
(HttpURLConnection)url.openConnection();
connection.addRequestProperty("x-api-key",
context.getString(R.string.open_weather_maps_app_id));
BufferedReader reader = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
StringBuffer json = new StringBuffer(1024);
String tmp="";
while((tmp=reader.readLine())!=null)
json.append(tmp).append("\n");
reader.close();
JSONObject data = new JSONObject(json.toString());
// This value will be 404 if the request was not
// successful
if(data.getInt("cod") != 200){
return null;
}
return data;
}catch(Exception e){
return null;
}
}
那些与地图有关
在清单中:
<permission
android:name="donate.cinek.wit.ie.ridetogether.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="donate.cinek.wit.ie.ridetogether.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza.............................." />
我说的任何其他代码都可以正常工作,所以没有太多要发布的地方,如果需要的话。谢谢