How to get latitude and longitude from network provider in kitkat

时间:2015-07-28 16:36:01

标签: android

when i am try to get latitude and longitude from network provider in kitkat the onLocationChanged method is not working. My code is:

   double dlat,dlang;
    listener = new MyLocationListener();        
    locationManager = (LocationManager)context. getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000,100, listener);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 100, listener);



    public class MyLocationListener implements LocationListener
{

    public void onLocationChanged(final Location loc)
    {


                dlat = loc.getLatitude();
                dlang = loc.getLongitude();



            }
        }
    }

0 个答案:

没有答案