package org.mortbay.ijetty.console; import javax.servlet.ServletConfig; import android.content.Context; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; public class GPSService { public String getGPSInfo(String requestURL, ServletConfig config) { Context androidContext = (Context) config.getServletContext() .getAttribute("org.mortbay.ijetty.context"); LocationManager mgr = (LocationManager) androidContext .getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); String best = mgr.getBestProvider(criteria, true); String result = best; Location location = mgr.getLastKnownLocation(best); if (location == null) { result += "\nLocation[unknown]"; } else { result += "\n" + location.toString(); } return result; } }