package com.josenaves.plugin;

import android.util.Log;
import android.location.LocationManager;
import android.content.Context;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;

public class CheckGps extends CordovaPlugin {

	private static final String TAG = CheckGps.class.getSimpleName();

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if ("isGpsEnabled".equals(action)) {

        	if (isGpsEnabled()) {
        		callbackContext.success("GPS is enabled");	
        	} else  {
        		callbackContext.error("GPS is not enabled");
        	}
            
            return true;
        }
        return false;  // Returning false results in a "MethodNotFound" error.
    }	

	private boolean isGpsEnabled() {
		LocationManager locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
		boolean enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
		Log.d(TAG, String.format("CheckGps.isGpsEnabled() = %s", enabled) );
		return enabled;
	}
}
@@ -621,16 +621,25 @@
 uccess(%22
+%3E%3E%3E%3E%3E%3E%3E%3E 
 GPS is e
@@ -644,16 +644,19 @@
  enabled
+ :)
 %22);%09%0A   
@@ -704,16 +704,25 @@
 .error(%22
+%3E%3E%3E%3E%3E%3E%3E%3E 
 GPS is n
@@ -731,16 +731,19 @@
  enabled
+ :(
 %22);%0A    

Change return messages