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;
}
Both the latitude and longitude variables give me the static-context error and also in the calling function. I've tried making them static variables but no luck. Any ideas?
In another part of the code I have but no matter what I do I get a static-context error somewhere:
final String url = getApiUrlFromAreaId(areaId);
static String getApiUrlFromAreaId ( String areaId ){
return URL + areaId;
}
No my programming is not up to par. Please bear with me
You got
which means that this method can be called without using class instance. As a consequence, everything that is used in that method, must be static as well (if not passed as argument).
I can only assume that either latitude,longitude or appId are not static. Either make them static as well, or remove
static
qualifier fromgetUrl
.