Created
October 1, 2014 15:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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