Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = {
- // Application Constructor
- initialize: function() {
- this.bindEvents();
- },
- // Bind Event Listeners
- //
- // Bind any events that are required on startup. Common events are:
- // 'load', 'deviceready', 'offline', and 'online'.
- bindEvents: function() {
- document.addEventListener('deviceready', this.onDeviceReady, false);
- },
- // deviceready Event Handler
- //
- // The scope of 'this' is the event. In order to call the 'receivedEvent'
- // function, we must explicitly call 'app.receivedEvent(...);'
- onDeviceReady: function() {
- function onSuccess(position){
- console.log("Latitude:" + position.coords.latitude);
- console.log("Longitude:" + position.coords.longitude);
- };
- function onError(error) {
- alert('code: ' + error.code + 'n' +
- 'message: ' + error.message + 'n');
- }
- navigator.geolocation.getCurrentPosition(onSuccess, onError);
- public boolean execute(String action, final JSONArray inputs, final CallbackContext callbackContext) throws JSONException {
- PluginResult result = null;
- if (action.equals("getCurrentPosition")) {
- this.cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- callbackContext.sendPluginResult(getCurrentPosition(inputs));
- }
- });
- result = new PluginResult(Status.OK);
- }
- }
- app.receivedEvent('deviceready');
- },
- THREAD WARNING: exec() call to Geolocation.getPermission blocked the main thread for 59ms. Plugin should use CordovaInterface.getThreadPool().
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement