Geçerli konumumu GPS olmadan almak için aşağıdaki kodu kullanıyorum, ancak koordinatları bir tostta göstermek istiyorum. Bu kodu denedim, ancak koordinatlar yerine paket ismimi gösteriyor!Android'de geçerli konum nasıl alınır?
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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);
Toast.makeText(getBaseContext(), "location is:"+locationListener, Toast.LENGTH_LONG).show();
}
Yaz Tost(). Yer. GetLat/LNG(). – VVB
bunu kontrol edin, gerçekten harika bir şeydir https://github.com/meetmehdi/GetAccurateLocation –