我得到了经纬度使用位置。并保存在
private double mLatitude;
private double mLongitude;.
mLatitude = location.getLatitude();
mLongitude =location.getLongitude();
locationMg =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setSpeedRequired(false);
criteria.setCostAllowed(true);
String bestProvider = locationMg.getBestProvider(criteria, true);
Location location = locationMg.getLastKnownLocation(bestProvider);
if(location != null){
Toast.makeText(this,"Latitude" +location.getLatitude()+"\n"+"Longitude"+location.getLongitude(), 0).show();
mLatitude = location.getLatitude();
mLongitude = location.getLongitude();
}
和
private String url ="http://api.openweathermap.org/data/2.5/weather?lat="+mLatitude+"&lon="+mLongitude+"&mode=xml";
运行此代码后,我看到了 LogCat。但是,0.0的经纬度的值就出来了。为什么?是不是因为字符串类型的url????????????和纬度和经度应该只类型是双。换个网址?
帮助。我不知道该怎么办。