I want to get Latitude and Longitude from my android application, without GPS. is there any way? I saw a tutorial here (http://www.tutorialspoint.com/android/android_location_based_services.htm) but i can't make an object of LocationClient as said in that tutorial. i also installed Google Play Service Sdk into my Application, even though i can't create an instance of LocationClient.
Asked
Active
Viewed 2,885 times
0
-
check out this one http://stackoverflow.com/questions/13761367/how-to-get-latitute-longitude-value-without-using-gps-in-android – Abed Elaziz Shehadeh Dec 15 '14 at 12:08
2 Answers
1
Use This code
private final LocationListener mLocationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onLocationChanged(Location location) {
double lat = location.getLatitude();
double lng = location.getLongitude();
Toast.makeText(MapActivity.this, lat+"" + lng +" ", Toast.LENGTH_SHORT).show();
}
};
put following line into onCreate()
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,10000,
1, mLocationListener);

Umesh Kumar Saraswat
- 758
- 3
- 10
- 28