Unable to return boolean from GPS check
<p>Im trying to detect if the GPS on my device is turned on.</p>

<p>Currently i am simply returning a boolean true or false value that then either proceeds with my code, or directs the users to the GPS settings.</p>

<p>At the moment when i return the boolean value my code is crashing. I have debugged it but still cannot see why as it it returning a value.</p>

<p>Here is the code:</p>

<pre><code>  GPSYesOrNo g = new GPSYesOrNo(this);

  check = g.checkStatus();
  // check if GPS enabled
  if (check == true) {
     Intent Appoint = new Intent("com.example.flybaseapp.appointmantMenu");
     startActivity(Appoint);
  } else {  
     alert();
  }
</code></pre>

<p>And the GPSYesOrNo class:</p>

<pre><code>public class GPSYesOrNo {
   Context cc;
   private LocationManager locationManager;
   boolean enable;

   public GPSYesOrNo(Context c) {
      this.cc = c;
      checkStatus();
   }

   public boolean checkStatus() {
      locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
      boolean enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 

      if (enabled) {
         return true;
      } else {
         return false;
      }
   }
}
</code></pre>

<p>Can anyone see where I am going wrong?</p>
