Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

native geolocation deprecated on Android #430

@mica16

Description

@mica16
Contributor

I struggle to make the geolocation works on Android, using ngCordova and of course the org.apache.cordova.geolocation plugin.

I came across this Jira:
https://issues.apache.org/jira/browse/CB-5977

Is ngCordova aware of this deprecation?

What is the best way today to use geolocation on Android with ngCordova?
Indeed, it seems that, when the plugin is installed, Android always try to use the native way, that..isn't available any more.

Should I write an ugly pseudo-code like:
if(window.cordova && isAndroid()) { useTheBrowserImplementation()} elseif(window.cordova && isIos()) {useNgCordova())} ?

Thanks a lot,

Michael

Activity

felquis

felquis commented on Nov 19, 2014

@felquis

@mica16 what errors you are getting with ngCordova? Because ngCordova already use the Web API ref

I'll make some tests with geolocation.

mica16

mica16 commented on Nov 22, 2014

@mica16
ContributorAuthor

@felquis I tested on Samsung S5, geolocation works.
On a Samsung S4, I don't get Javascript errors...but I don't get any data. I did:

return $cordovaGeolocation.getCurrentPosition({
                    enableHighAccuracy: true
                }).then(function (position) {
                    alert(JSON.stringify(position));
                    return {
                        lat: position.coords.latitude,
                        lon: position.coords.longitude
                    };
                }, function (error) {
                    alert(JSON.stringify(error));
                    return $q.reject(error);
                });

No Javascript alert is displayed at all, meaning that ngCordova doesn't return a promise in this case...

Actually, when I don't set the "Position" option (to get the local position of the phone user) on the Samsung parameter section, I don't get any data..and no errors is displayed...
I expected some errors to appear, involved by the promise.
=> can't use the app if "Position" is not set.

steefaan

steefaan commented on Dec 15, 2014

@steefaan

@mica16 Any updates on this? Unfortunately I can't test on Samsung Galaxy S4 but I tested it on Samsung Galaxy S3, Samsung Galaxy S5 and Galaxy Tab 4 and it works for all. The problem I have with Android 4.4 in general is that WiFi is not able to find the location. On my Samsung Galaxy S3 the WiFi geolocation works fine.

mica16

mica16 commented on Dec 16, 2014

@mica16
ContributorAuthor

Hi,

Actually, I noticed that when the property enableHighAccuracy is set to true, the phone has to enabled GeoPosition, otherwise the Geolocation by the browser is not used, explaining my post above.
I found it very frustrating for certain lambda users that aren't aware about their phone settings.

Personally, in the context of my app, I set enableHighAccuracy to false, in order to benefit from the browser solution, in case were the GPS wasn't enabled.

steefaan

steefaan commented on Dec 17, 2014

@steefaan

You got the WiFi geolocation working with enableHighAccuracy to false? For me it doesn't work. If I try to find the geolocation with disabled GPS on Android 4.4 nothing happens and it runs into a timeout.

mica16

mica16 commented on Apr 2, 2015

@mica16
ContributorAuthor

I found a tricky bug:
Having this code:

$cordovaGeolocation.getCurrentPosition({
                    enableHighAccuracy: true,
                    timeout: 15000
                })

and in the Android phone settings about "Position", the radio button set on "GPS only",
It ALWAYS reachs the timeout !
All users argued me that my queries were too long (more than 15 seconds in this case), but when I tell them:
"Try to set the Position mode to 'High accuracy'", they say: wow now it's fast !

Question so: why is timeout reached even when 'enableHighAccuracy: true' when using GPS ONLY ?

Here's a related stackoverflow question I found on the subject but no answer..:

http://stackoverflow.com/questions/27835425/html5-geolocation-not-working-with-gps-only-location-service-mode-on-android

And here's mine I asked:

http://stackoverflow.com/questions/29411697/timeout-about-geolocation-always-reached-when-position-mode-is-set-to-device-on

sean-hill

sean-hill commented on Apr 8, 2015

@sean-hill

I'm having this exact same issue, any updates to this?

mikeon

mikeon commented on May 8, 2015

@mikeon

I also, didn't find solution for that issue.

Kukiwon

Kukiwon commented on Jul 9, 2015

@Kukiwon

+1 seeing the same issues on Galaxy S3 mini running Android 4.4.4

mikeon

mikeon commented on Jul 9, 2015

@mikeon

@Kukiwon Did you try to install Crosswalk? Because this is remedy. Also you can create function with setinterval, at first run it will fail but next one will execute properly.

Kukiwon

Kukiwon commented on Jul 9, 2015

@Kukiwon

@mikeon yes i'm using crosswalk. I'll try using an interval for getting a location and will keep you posted.

Kukiwon

Kukiwon commented on Jul 10, 2015

@Kukiwon

@mikeon your proposed solution using an interval did not work for me. Eventually we reinstalled Android on the phone and now it works. Looks like it was an issue with the device. Thanks again!

askannan

askannan commented on Sep 19, 2015

@askannan

same issue as mica16... Is there a way out, or is there some other plugin that I can use?

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mica16@felquis@sean-hill@pbernasconi@Kukiwon

        Issue actions

          native geolocation deprecated on Android · Issue #430 · ionic-team/ng-cordova