4 Replies Latest reply on Sep 13, 2017 6:23 AM by blgsyrmhnds

    Geolocation fails if app sent to background then resumed (Android)


      I'm having a peculiar problem where geolocation works perfectly when the app is originally started, but if the user navigates to another app and comes back, it fails.

      More specifically, it does nothing. The success or error callbacks are never called, and setting a timeout does not affect this. I am using Phonegap Build to compile the app from html and javascript.


      Config file:


      <?xml version='1.0' encoding='utf-8'?>

      <widget id="com.sbeco.timesheetapp" version="1.1.0" versionCode="10" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">



              A internal-use only app to track employee time


          <author email="myemail" href="mywebsite">

              Jeff Gordon


          <content src="index.html" />



          <access origin="*" />

          <allow-intent href="*" />

          <allow-navigation href="*" />





          <plugin name="cordova-plugin-whitelist" spec="1"/>

          <plugin name="cordova-plugin-geolocation" />

          <plugin name="cordova-plugin-device" spec="1"/>

          <plugin name="cordova-plugin-media-capture" spec="1"/>



      Code snippet that utilizes geolocation:

      new Promise(

           function (resolve, reject){



                     //my code here



                function(){alert('there was a problem aquiring your location'); reject();},

                {timeout:10000, maximumAge:0, enableHighAccuracy:true});