Code example for LocationManager: Finding current location

Methods: getLastKnownLocation

0
    } 
  }; 
   
  public class Locater { 
    public String getLocation() throws JSONException {
      Location loc=myLocationManager.getLastKnownLocation(PROVIDER);
       
      if (loc==null) {
        return(null); 
      } 
       
      JSONObject json=new JSONObject();
 
      json.put("lat", loc.getLatitude());
      json.put("lon", loc.getLongitude());
       
      return(json.toString());
    } 
  } 
} 
Contextual code suggestions in your IDE  Get Codota for Java