I've been looking at the right way to work with the following code which is in my MainActivity and pull the result in to another activity so I can call a URL of 'http://www.website.com?lat:lng:speed:bearing' which will be based on the values pulled through.
locationCheck() sits in my Mainactivity how ever I have a JSONParse activity which I want to use the location found to construct the url. What I do not is how to share the result.
In HTML or PHP I would use a global value.
Although I can call and toast on create I have not found the best way to share the result.
public void locationCheck() {
MyLocation myLocation = new MyLocation();
// this is the result
myLocation.getLocation(this, locationResult);
}
public LocationResult locationResult = new LocationResult() {
public void gotLocation(final Location location) {
try {
double lat = location.getLatitude();
double lng = location.getLongitude();
if (lat != 0.0 && lng != 0.0) {
String sLat;
String sLng;
sLat = Double.toString(lat);
sLng = Double.toString(lng);
String gps_location = sLat + " : " + sLng;
Toast.makeText(getBaseContext(),
"We got gps location! " + gps_location + "",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
}
}
};