public Locator(Context mContext){
getLocation();
this.mContext = mContext;
}
public void setLatitude ( String lat ){
this.latitude = lat;
}
public String getLatitude ( ){
return latitude;
}
public void setLongitude ( String lon ){
this.longitude = lon;
}
public String getLongitude ( ){
return longitude;
}
public void getLocation ( ){
LocationManager lm = (LocationManager)mContext.getSystemService ( Context.LOCATION_SERVICE );
Location location = lm.getLastKnownLocation ( LocationManager.GPS_PROVIDER );
longitude = String.valueOf(location.getLongitude());
latitude = String.valueOf(location.getLatitude());
}
public static String getURL(){
return "api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "APPID=" + APPID;
}
纬度和经度变量都给了我静态上下文错误以及调用函数。我试过让它们成为静态变量,但没有运气。有任何想法吗?
在我拥有的另一部分代码中,但无论我做什么,我都会在某处遇到静态上下文错误:
final String url = getApiUrlFromAreaId(areaId);
static String getApiUrlFromAreaId ( String areaId ){
return URL + areaId;
}
不,我的编程达不到标准。请多多包涵
一只名叫tom的猫
月关宝盒
相关分类