0

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.

Muhammed Shuhaib
  • 314
  • 6
  • 20

2 Answers2

2

check out this

you can get location without using GPS

Fused location provider

uday
  • 1,348
  • 12
  • 27
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