Skip to content

Instantly share code, notes, and snippets.

@johnpc
Created October 1, 2014 15:10
Show Gist options
  • Save johnpc/bb94f79df849a4cf14fb to your computer and use it in GitHub Desktop.
Save johnpc/bb94f79df849a4cf14fb to your computer and use it in GitHub Desktop.
This class determines whether android device has an location services (GPS) enabled, called from JavaScript using Cordova.
package org.apache.cordova.plugin;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.location.LocationManager;
/**
* This class determines whether android device has an location services (GPS) enabled, called from JavaScript using Cordova.
**/
public class hasLocation extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if( !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ) {
return false;
});
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment