Stop LocationManager Updates
<p>I'm trying to have GPS coordinates sent to a text message.  This code works, but every time the GPS updates location, it tries to send a new text message.  I can't figure out how to stop the location updates.  This is what I have currently...I realize it may not be the most efficient way to do it.</p>

<p>Any help would be appreciated!</p>

<pre><code>  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    LocationListener mlocListener = new MyLocationListener();
    mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);

}

public void GPSDisable() {
    LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    LocationListener mlocListener = new MyLocationListener();
    mlocManager.removeUpdates(mlocListener);
}

public class MyLocationListener implements LocationListener {

    @Override

    public void onLocationChanged(Location loc) {

        loc.getLatitude();
        loc.getLongitude();

        double latitude = loc.getLatitude();
        double longitude = loc.getLongitude();

        Intent smsIntent = new Intent(Intent.ACTION_VIEW);
        smsIntent.setType("vnd.android-dir/mms-sms");
        smsIntent.putExtra("address", "5555555555");
        smsIntent.putExtra("sms_body", "Location:"+latitude+","+longitude);
        GPSDisable();
        startActivity(smsIntent);

    }


    @Override

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

    {

    }


    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

}

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub

}

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub

}
</code></pre>

<p>}</p>
