detect gps disabled
<p>I have this code to get my GPS position:</p>

<pre><code>    public void run() {

        mLocationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);

        if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {

            Looper.prepare();

            mLocationListener = new MyLocationListener();
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocationListener);

            Looper.loop(); 
            Looper.myLooper().quit(); 

        } else {

            //Never be here!!!

        }
}

private Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        pd.dismiss();
        mLocationManager.removeUpdates(mLocationListener);

        if (currentLocation!=null) {

                  //found. OK
        }
    }
};

private class MyLocationListener implements LocationListener {
    @Override
    public void onLocationChanged(Location loc) {
        if (loc != null) {
            setCurrentLocation(loc);
            handler.sendEmptyMessage(0);

        }
    }

    @Override
     public void onProviderDisabled(String provider) {
         //If I disable de GPS I have an error
     }

    @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>how can I detect the GPS disabled and too time looking for data?</p>

<p>I thought that onProviderDisabled detect that event, but, my code never go there. I got this exception:</p>

<p>Cant create handler inside thread that has not called Looper.prepare</p>

<p>Thank you in advance</p>
