I'm building an Android app to take a picture and your current location and send it to server. I'm using AngularJs and Apache Cordova to do so. On the back-end, I'm using Web API and Entity Framework.
I managed to take the picture, but when I try to get current location, the app freezes. Android won't return error, and javascript console won't too (debbuging on Chrome DevTools). It simply stops responding, even if I set a timeout for the request.
Here is my code:
$scope.send = function () {
navigator.geolocation.getCurrentPosition(
function (success) {
console.log("success")
},
function (error) {
console.log("error")
},
{timeout: 15000}
)
}
I used ngCordova to take the picture, and tried to use it for location too, but as it was freezing, tried to use this way (maybe it was a problem on ngCordova). But the result is the same.
I searched for it on the web, but haven't found anything that would solve the problem yet..
I've been here already:
Phonegap Geolocalisation application crashes
Cordova geolocation plugin doesn't work on android
If any other piece of code is needed, please let me know.
Thanks in advance!
EDIT: I tested it on another Android phone, and the result is the same.
EDIT 2: I created a blank app on visual studio, and GeoLocation worked with that code. Just copied and pasted.
I found the problem.
I use require.js to load scripts. I was loading the initCordova (script that also uses require) before cordova.js itself. Just made sure to load then in correct order and it started working.
But it is interesting that the Camera Plugin worked fine.