Get user current and exact location using GPS
本问题已经有最佳答案,请猛点这里访问。
对于我的新应用,我需要使用GPS获取用户位置。 为此,我使用
您可以在
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Acquire a reference to the system Location Manager LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. makeUseOfNewLocation(location); } public void onStatusChanged(String provider, int status, Bundle extras) {} public void onProviderEnabled(String provider) {} public void onProviderDisabled(String provider) {} }; // Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); |