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

Android: "locationServicesEnabled" returns false when available on device

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 5.2.1
    • Fix Version/s: Release 7.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      SDK 5.1.2.GA
      Nexus 5 running Android 6.0.1

    • Sprint:
      2017 Sprint 09 SDK

      Description

      On an Android 6.0 device Ti.Geolocation.locationServicesEnabled will return false while it works fine. On an Android 4.4.4 emulator it returns true while it does not.

      Meanwhile documentation says since Android 2.2 it will always return true because of the "passive" location provider but looking at the source it filters that out.

      var win = Ti.UI.createWindow();
       
      var btn = Ti.UI.createButton({
        title: 'Click Me'
      });
       
      btn.addEventListener('click', function(e) {
        console.log('Ti.Geolocation.locationServicesEnabled ' + Ti.Geolocation.locationServicesEnabled);
       
        console.log('Ti.Geolocation.hasLocationPermissions() ' + Ti.Geolocation.hasLocationPermissions());
       
        if (Ti.Geolocation.hasLocationPermissions()) {
          getCurrentPosition();
       
        } else {
          Ti.Geolocation.requestLocationPermissions(null, getCurrentPosition);
        }
      });
       
      function getCurrentPosition() {
        Ti.Geolocation.getCurrentPosition(function(e) {
          console.log('Ti.Geolocation.getCurrentPosition() ' + JSON.stringify(e));
        });
      }
       
      win.add(btn);
      win.open();
      

      Android 6.1

      [INFO]  Ti.Geolocation.locationServicesEnabled false
      [INFO]  Ti.Geolocation.hasLocationPermissions() false
      [INFO]  Ti.Geolocation.getCurrentPosition() {"code":0,"provider":{"power":1,"name":"network","accuracy":2},"coords":{"altitude":0,"speed":0,"longitude":5.9043011,"heading":0,"latitude":52.9589968,"timestamp":1459535042207,"altitudeAccuracy":null,"accuracy":22.777000427246094},"success":true}
      

      Android 4.4.4

      [INFO]  Ti.Geolocation.locationServicesEnabled true
      [INFO]  Ti.Geolocation.hasLocationPermissions() true
      [ERROR] GeolocationModule: (KrollRuntimeThread) [3070,3070] Unable to get current position, location is null
      [INFO]  Ti.Geolocation.getCurrentPosition() {"error":"location is currently unavailable.","success":false,"code":6}
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Gary Mathews
                Tester:
                Josh Longton
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code