Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20522] FusedLocationProvider on Android

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-02-21T21:25:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.1.0
ComponentsAndroid
Labelsn/a
ReporterJoseph Sachs
AssigneeGary Mathews
Created2016-03-05T13:06:58.000+0000
Updated2021-03-30T09:11:20.000+0000

Description

Comments

  1. Sharif AbuDarda 2016-03-06

    Hello, Thanks for reaching out. This is a valid new feature request. Our engineers will look into it for further process.
  2. Joseph Sachs 2016-03-18

    I've noticed a lot more developers are watching this ticket. I wonder if it would be possible to increase the priority on this feature?
  3. Joe Falcone 2016-05-15

  4. Joseph Sachs 2016-05-15

    @Joe it dosen't; This ticket is simply the newer/better way of getting the geolocation of the user on Android.
  5. Ashraf Abu 2016-06-02

    [~underlabs] Just wondering, which module are you using that provides the FusedLocationProvider?
  6. Joseph Sachs 2016-06-02

    It was a paid (closed) module a few years ago. The developer offers no support anymore.
  7. Danny Pham 2016-06-02

    I have developed this module with FusedLocationProvider. It should not be distributed, please remove the Dropbox link.
  8. Joseph Sachs 2016-06-02

    It's been removed from Dropbox. However, @Danny, maybe you can help on this ticket since you developed the module.
  9. Danny Pham 2016-06-02

    I haven't updated the module since SDK 5.0.2 ... will do it probably next month. The AppC team is much more experienced in native development. I don't think they need my help to implement this feature request.
  10. Rene Pot 2016-09-21

    It seems this ticket has no attention. Is it possible to increase priority for this ticket?
  11. Hans Knöchel 2016-09-21

    It is a feature-ticket and our Android-team currently has priority-bugfixes to work on, so we can't schedule it, yet.
  12. Joseph Sachs 2016-12-11

    Can't update one of our bigger Apps to 6.x due to one closed-module which uses Fused-Location. I agree with [~Topener] this should be a high priority, as this is the proper way to implement Geolocation. The current API Ti uses on Android is far too old and not recommended.
  13. Joseph Sachs 2017-01-23

    Any update on this 'really important' feature?
  14. Miguel Ángel Castaño 2017-01-23

    +1
  15. Eric Merriman 2017-01-23

    Hello all, This sprint we will scope the work we think will be required for implementation. Once I have that, we can schedule it, but at this point I can't say when that will be. Stay tuned.
  16. Joseph Sachs 2017-01-31

    After two full days trying to get this running, I do have an Android Module https://github.com/yozef/FusedLocation (basically my first Android Module & playing around in Java). This Module works on it's own in a Ti App; However this Module *does Not work with ti.map* due to google-play-services.jar having similar classes in both modules. I see two options: - Maybe this module can help implement it in Ti.Geolocation by the AppC Devs - Maybe someone can figure out a way to fix google-play-services of FusedLocation (pull-request) in order to with Ti.Map in the same Ti Android App.
  17. Danny Pham 2017-01-31

    Looks like you have debugged my module, which tool did you use?
  18. Joseph Sachs 2017-01-31

    Hi Danny, I worked on it with Rainer Knoterich. Can you help with google-play-services issue?
  19. Danny Pham 2017-01-31

    Even the log messages are in the same place as in my original code, seriously?!
  20. Joseph Sachs 2017-01-31

    What log Messages? Your original module hasn't been touched in over 2 years mate. The issue we have is this, when used with other Android Module (such as Ti.Map):
        Running FusedLocation with ti.map will throw errors:
        [ERROR] :  Failed to run dexer:
        [ERROR] :  
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzrn;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzro;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzrl;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzsv;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzsu;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzrm;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/zze;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/zzc;
        [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/ConnectionResult;
        
    If you can help, I'm on TiSlack
  21. Danny Pham 2017-01-31

    My module works perfect with Ti SDK 6.0. It's quite simple, just use the correct Google Play lib.
  22. Joseph Sachs 2017-02-01

    Just released FusedLocation android module: https://github.com/yozef/FusedLocation It returns a location object, exactly like how iOS would return the location object (also has some hardcoded values like DistanceFilter, etc; )
        {"type":"location","success":true,"provider":"fused","coords":{"bearing":44,"latitude":65.9667017,"timestamp":1486006304000,"speed":0,"accuracy":1,"longitude":-18.5312533}}
        
  23. Ygor Lemos 2017-03-23

    +1 for this ticket since it brings better parity with iOS and it is the recommended native way of implementing location-awareness on native Android apps.
  24. Rene Pot 2017-07-11

    I see this one is keep being pushed back. Is there a reason for this? For when is it actually planned?
  25. greg 2017-09-28

    Has this one ended up in the too hard pile as there has been no activity on this for months.
  26. joshlambertmobile 2017-10-31

    Any update on this being implemented?
  27. Joseph Sachs 2017-11-16

    This module stopped working after Ti 6.1.2.GA due to Google Play Services conflicts & I can't seem to get it to work with latest/updated .jar. Can we bump the priority on this ticket please, since we can't update to the latest Ti SDK for Android builds.
  28. Gary Mathews 2017-11-29

    master: https://github.com/appcelerator/titanium_mobile/pull/9634
  29. Rene Pot 2017-12-04

    Love that there is a PR for this. Is there any way this can get backported in the 6.# branch? A 6.4 version for example.
  30. Gary Mathews 2018-02-15

    7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9826
  31. Lokesh Choudhary 2018-02-16

    FR Passed for both master & backport. Waiting for CR.
  32. Lokesh Choudhary 2018-02-21

    PR's merged.
  33. Lokesh Choudhary 2018-03-06

    Verified the fix in SDK 7.2.0.v20180305152636 & 7.1.0.v20180306061214. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12 Appc CLI: 7.0.2 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 — Android 6.0.1 ⇨ google Nexus 6P — Android 8.0.0
  34. Joseph Sachs 2018-03-29

    Has anybody been able to run this module and have Location Update every 5 meters. Seems that regardless of the LocationProvider and LocationRules on Android, the geolocation triggers only after a fixed 30 seconds time laps. I assume it's due to the hardcoded final consts here: https://github.com/garymathews/titanium_mobile/blob/c4cc7bef37b8f48d3f23e5536493ece4b2b0fd0e/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java#L184 This is the Code I am trying to test on Simulator, with Ti 7.1.x the Fused Location should adhere to the settings:
        	Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
        	// Location Provider
        	gpsProvider = Ti.Geolocation.Android.createLocationProvider({ // Outside the Airport
        	    name: Ti.Geolocation.PROVIDER_GPS, minUpdateDistance: 1
        	});
        	wifiProvider = Ti.Geolocation.Android.createLocationProvider({ // Inside the Airport
        	    name: Ti.Geolocation.PROVIDER_NETWORK, minUpdateDistance: 1, minUpdateTime: 1
        	});
        	Ti.Geolocation.Android.addLocationProvider(gpsProvider);
        	Ti.Geolocation.Android.addLocationProvider(wifiProvider);
        	
        	// Trigger Rules
        	var gpsRule = Ti.Geolocation.Android.createLocationRule({
            provider: Ti.Geolocation.PROVIDER_GPS,
        	    accuracy: 65, maxAge: 1, minAge: 1
        	});
        	var wifiRule = Ti.Geolocation.Android.createLocationRule({
            provider: Ti.Geolocation.PROVIDER_NETWORK,
        	    accuracy: 7, maxAge: 1, minAge: 1
        	});
        	Ti.Geolocation.Android.addLocationRule(gpsRule);
        	Ti.Geolocation.Android.addLocationRule(wifiRule);
        ...
        if (Ti.Geolocation.hasLocationPermissions()) 
            Ti.Geolocation.addEventListener('location', handleLocation); // traces out every 30 seconds the location
        
    This fires location event every 30 seconds, whereas it should update every provider settings and/or LocationRules settings. Maybe I'm missing an example to show this in action?
  35. Joseph Sachs 2018-03-29

    My mistake... it Works! All I needed was to make sure this was added: Ti.Geolocation.Android.manualMode = true;
  36. john adamis 2021-03-29

    Guys, I believe this part of code is really poorly documented. The only reference is : "Starting at TiSDK 7.1.0.GA there is support for FusedLocationProvider. To enable this, the only thing you need to do is include the Ti.PlayServices module in your app. This will enable battery efficient geolocation API's in your app." In my case this was NOT the only changed required. At manualMode you say : "Manual mode gives developers low-level control of location updates, including enabling individual location providers and filtering updates, for the best combination of accuracy and battery life. Manual mode is used when the Titanium.Geolocation.Android.manualMode flag is set to true. In manual mode, the accuracy property is not used, and all configuration is done through the Titanium.Geolocation.Android module." For FuseLocation however even though manualMode must be set, accuracy property needs to be set for having high accuracy values. Also accuracy has to be set AFTER manualMode, otherwise minUpdateDistance and minUpdate values are not respected. All these are not mentioned anywhere at documentation. Also I couldn't find a way to use the old location provider but for removing play services library. It would be convenient to have this as a pref because someone might want to keep the old library but add play services for other features (like maps or firebase)
  37. Michael Gangolf 2021-03-30

    [~peaceofmind7] Valid points! Documentation can always be improved to help others. You could either add some valid information to https://github.com/appcelerator/titanium_mobile/tree/master/apidoc/Titanium/Geolocation or start a conversation at: https://github.com/appcelerator/titanium_mobile/discussions so others can join in and help in finding the best text for the documentation. I only use Fused it in non-manual mode and it "just works" :) But for other use cases it might be very useful to know those parts!

JSON Source