Time taken by an android gps device to get its latitude and longitude
<p>I am trying an code for finding latitude and longitude but takes lot of time to give coordinates or does not give the coordinates at all, what could be the problem. I am trying my code on Samsung Galaxy tab.</p>

<pre><code>LocationManager mlocManager;
double lat,lng; 
 LocationListener mlocListener = new MyLocationListener();
</code></pre>

<p>I call the below code in onCreate() method</p>

<pre><code>mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
</code></pre>

<p>Listener MyLocationListener class code is below</p>

<pre><code> public class MyLocationListener implements LocationListener

        {




        @Override
        public void onLocationChanged(Location loc){

        loc.getLatitude();

        loc.getLongitude();

        String Text = "My current location is: " + "Latitude = " + loc.getLatitude() + "Longitude = " + loc.getLongitude();
        String latLongString = "";
        if (loc != null) {
            lat = loc.getLatitude();
            lng = loc.getLongitude();
            latLongString = "Lat:" + lat + "\nLong:" + lng;
            TextView myLocationText = (TextView)findViewById(R.id.FindUsTextView);
            myLocationText.setText("Your Current Position is:\n" + latLongString);
            System.out.println(latLongString);

        } 
       /* findUsProgressbarField.setVisibility(View.INVISIBLE);*/
        Toast.makeText( FindUs.this, Text, Toast.LENGTH_SHORT).show();
        mlocManager.removeUpdates(mlocListener);

        }

        @Override

        public void onProviderDisabled(String provider){

        Toast.makeText( getApplicationContext(),"Gps Disabled, Please Enable the GPS", Toast.LENGTH_SHORT ).show();

        }

        @Override

        public void onProviderEnabled(String provider){

        Toast.makeText( getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show();

        }

        @Override

        public void onStatusChanged(String provider, int status, Bundle extras){

        }



        }
        @Override
        protected void onDestroy() {
        super.onDestroy();
        if (mlocManager != null) {
            mlocManager.removeUpdates(mlocListener);
            mlocManager = null;
        }
        }
</code></pre>

<p>What could be the problem, any pointers or have I not considered some points.
Looking forward to your reply.
thanks.</p>
