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

Android : Geolocation callback is not being called on android 6.0

    Details

    • Type: Bug
    • Status: Closed
    • Priority: None
    • Resolution: Invalid
    • Affects Version/s: Release 5.1.0
    • Fix Version/s: None
    • Component/s: Android
    • Labels:
    • Environment:

      Description

      Steps To Reproduce:
      1. Use the code below in the app.js.

      var win1 = Titanium.UI.createWindow({
          title : 'Tab 1',
          backgroundColor : '#fff'
      });
       
      var latitude = 33.58262112511852;
      var longitude = -111.71566843986511;
       
      var locationCallback = function(e) {
          if(!e.success || e.error) {  
              alert('error:' + JSON.stringify(e.error));  
              return;  
          }
          Ti.API.info(JSON.stringify(e));
       
          var longitude = e.coords.longitude;
          var latitude = e.coords.latitude;
       
      };
      win1.addEventListener("open", function(e) {
       
          if (Ti.Geolocation.hasLocationPermissions()) {
              Ti.Geolocation.preferredProvider = "gps";
              Titanium.Geolocation.addEventListener('location', locationCallback);
          } else {
              Ti.Geolocation.requestLocationPermissions(function(e) {
                          if (e.success === true) {
                              Ti.Geolocation.preferredProvider = "gps";
                              Titanium.Geolocation.addEventListener('location', locationCallback);
                          } else {
                              alert("Access denied, error: " + e.error);
                          }
              });
          }
      });
       
      win1.open();
      

      2. Build the app on android device running android 6.0.
      3. After the app launches the app would ask permission to access location.
      4. Grant access by tapping ok
      5. Let the app launch & check the logs in studio console.

      Actual Results:

      1. The location callback is not called & no info is seen relating to location in the console.
      2. Works fine with android 5.1.1, android 4.4.4.
      Android 5.1.1 logs:

      [INFO] :   {"type":"location","source":{"bubbleParent":true,"hasCompass":true,"__propertiesDefined__":true,"_events":{"location":{}},"preferredProvider":"gps","lastGeolocation":"{\"latitude\":37.3676949,\"longitude\":-121.9137751,\"altitude\":0,\"accuracy\":67.5,\"heading\":0,\"speed\":0,\"timestamp\":1445290117314}","locationServicesEnabled":true,"apiName":"Ti.Geolocation"},"provider":{"power":1,"name":"network","accuracy":2},"coords":{"altitude":0,"speed":0,"longitude":-121.9137751,"heading":0,"latitude":37.3676949,"timestamp":1445290117314,"altitudeAccuracy":null,"accuracy":67.5},"bubbles":false,"success":true,"code":0,"cancelBubble":false}
      

      Expected Results:

      1. The location callback should be called & location info should get printed in the console

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cng Chee Kiat Ng (Inactive)
                Reporter:
                lchoudhary Lokesh Choudhary
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration