Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25974

Android: Ti.Geolocation updates rarely on Android 8.0 while app is backgrounded

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.3.0
    • Component/s: Android
    • Environment:

      Description

      Issue Overview:
      I need my app to get the location every 5 seconds.
      It seems when the phone becomes 'locked' and the screen goes off, the location updates very rarely. If I request the location the timestamp of the location object doesn't change.
      I've tried manual mode but I get the same result.

      How can I get the realtime location when the phone is on or off?

      Reproduction:
      Run the test code
      Check the log and observe that the timestamp never changes. So it seems the geolocation doens't expire after 10 seconds.

      index.js

      function getLocation() {
          Ti.Geolocation.addEventListener('location', function(e) {
              alert(JSON.stringify(e, null, 2));
          });
      }
       
      $.win.addEventListener('open', function() {
          if (Ti.Geolocation.hasLocationPermissions()){
              getLocation();
           } else {
              Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
                  if (e.success) {
                      getLocation();
                  } else {
                      alert('could not obtain location permissions');
                  }
              });
          }
      });
       
      Ti.Geolocation.Android.manualMode = true;
      var gpsProvider = Ti.Geolocation.Android.createLocationProvider({
      name: Ti.Geolocation.PROVIDER_GPS,
      minUpdateTime: 5,
      minUpdateDistance: 1
      });
       
      var gpsRule = Ti.Geolocation.Android.createLocationRule({
      accuracy: 100,
      maxAge: 10000,
      });
       
      Ti.Geolocation.Android.addLocationRule(gpsRule);
      setInterval(function(){
      Titanium.Geolocation.getCurrentPosition(function(e){
      var accuracy = e.coords.accuracy;
      var timestamp = e.coords.timestamp;
      var report = 'geo time: ' + new Date(timestamp) + ', accuracy: ' + accuracy;
      //$.label.text = report;
      console.log(report);	
      });
      },5000);
      

      Output

      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      [INFO] : geo time: Wed Apr 18 2018 11:06:28 GMT+0100 (BST), accuracy: 18.344999313354492
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jnaher Jebun Naher
                Reviewer:
                Gary Mathews
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-6308
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code