I am working in android. i want to get GPS coordinates of my android device.
I am using this code to get my coordinates:-
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = mlocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            if(location!=null) {
               myLongitude = location.getLongitude();
               myLatitude= location.getLatitude();
            }
            else {
               myLongitude =0;
               myLatitude= 0;
            }
           LocationListener mlocListener;
           mlocListener = new MyLocationListener();
           mlocManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, mlocListener);
and this the class:-
 public class MyLocationListener implements LocationListener
 {
    @Override
    public void onLocationChanged(Location loc)
    {
        myLatitude= loc.getLatitude();
        myLongitude=loc.getLongitude();
    }
}
but all the time i get latitude and longitude to zero only. please suggest me what mistake i have done.
Thank you in advance.
 
     
    