Cordova Ionic Android Location Sometimes Not Accurate - android

We use in Cordova with plugin "cordova-plugin-locationservices"
Sometimes we get location that a few km away from real location.
we call to "getCurrentPosition" with next options:
{
timeout: 60000,
enableHighAccuracy: true,
maximumAge: 0,
}
Someone use in this plugin and use in another options or recommend on another plugin.
At first we use "cordova-plugin-geolocation" with same options but it's also sometimes return not accurate position.

I've written extensively on this topic at https://breautek.com/articles/geolocation-accuracy.html
But to summarise there are a number of reasons why you aren't receiving the accuracy that you're after.
The two main contributors to inaccurate readings are 1) Settings & 2) The environment.
Natively, the GPS service operates in two modes: Fine location and coarse location. Fine location will allow you to get approximately up to 3-5 meter accuracy and is generally used if you require information such as the specific street. Coarse location gives you a very low accuracy reading that can only be useful to determine the location of the user's state or country.
Settings includes both programmatic settings, such as the enableHighAccuracy parameter, and they include User device settings, which is configurable by the user on based on their own location preferences.
The developer obviously has control over programmatic settings, and it looks like you're doing just that. However, the developer doesn't have access to change user preferences of the device. Just because the user has consented permission for your app to use location, doesn't mean they have location services actually enabled, or even configured to provide fine location. The specific settings can vary from device to device or by OS version to OS version. But generally speaking they usually have some sort of "Device/GPS only", and "High Accuracy" (sometimes labelled as "Bluetooth/Wifi/Mobile") setting for geolocation. It's the app's responsibility to handle these situations.
In my apps, I use the mixture of the cordova-plugin-geolocation as well as the third-party diagnostics plugin. With the diagnostics plugin, you can check if permission is granted, including for fine/precise location, as well if location services are indeed enabled.
Lastly, the second issue could be the environment. Even if the device is configured and the app has permission to use fine location, you still may not actually receive accurate readings. This can be caused purely based on the environment. Being located in a concrete office building for example hinders a lot of GPS capabilities.
It's recommended to pay attention to the accuracy field in your GPS callbacks, which will tell how confident the GPS service is that the given GPS point is accurate. The accuracy reading is in meters which tells you that the true location is within X meters radius of the given location. So in otherwords, the lower the number the better.

Related

Android location mode, no GPS, options in AOSP

I'm working on an Android M STB without a GPS chip. In Android settings, Location, I get three choices for Location support -- High Accuracy, Low Bat, GPS Only. The system is defaulting to High Accuracy mode.
The problem here is that when wifi.getScanResults() is called from a background service and one of the location modes needing GPS is enabled, I don't get any results back. The call works fine from a foreground app, only background services are impacted by this. When I change the system over to Location mode Low Bat (which does not require GPS) the background getScanResults() call works as expected.
How do I modify my AOSP build so that the High Accuracy and GPS Only choices won't be presented to the user since there is no GPS chip?
Have you tried modifying the LocationManagerService class so it doesn't load a GPS provider? The following might be what you are looking for.
https://github.com/android/platform_frameworks_base/blob/nougat-release/services/core/java/com/android/server/LocationManagerService.java#L453
The default location mode is set by def_location_providers_allowed in frameworks/base/packages/SettingsProvider/res/values/defaults.xml. Its value can be either gps (GPS only), network (Battery saving) or gps,network (High accuracy).
You could therefore set def_location_providers_allowed to network (e.g. in a device/vendor overlay) and disable or hide the Mode option to the user in Settings → Location since you have only one choice (see packages/apps/Settings/res/xml/location_mode.xml).

Android GPS location accuracy issue

I am working on gps tracking apps in android. Here is my code architecture:
BackgroundSyncService : A service class that is used for getting location update. Here GoogleApiClient is initialized and implements others Location related methods.
AppRunCheckerReceiver : A BroadcastReceiver class that will check if my BackgroundSyncService is running or not in a time interval. If it stopped then it start.
GpsEnableReceiver : A BroadcastReceiver it will fire if gps status changed. It will check if my BackgroundSyncService is running or not in a time interval. If it stopped then it start.
InternetConnectionStateReceiver : A BroadcastReceiver it will fire when internet status changed. It will check if my BackgroundSyncService is running or not in a time interval. If it is stopped, then it start.
In my BackgroundSyncService service I initialize the GoogleApiClient using this way:
public void setLocationLocationRequest() {
try {
googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(com.google.android.gms.location.LocationServices.API).build();
locationRequest = new LocationRequest();
locationRequest.setInterval(3000);
locationRequest.setFastestInterval(3000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
googleApiClient.connect();
} catch (Exception e) {
}
Here accuricy is LocationRequest.PRIORITY_HIGH_ACCURACY and interval is
locationRequest.setInterval(3000)
here is the GoogleApiClient implementation code.
This application GPS info section contains Latitude longitude and Accuracy parameter
My Findings: in onLocationChanged(Location location) method I check the accuracy of Location object in this way : location.getAccuracy(). Here if accuracy is less than 50 meter, then I accept it.
In 85% of the cases it working like a charm. It sending me exact location from GPS. But in 15% cases, it sending me inaccurate location like more >300 meter.
The 15% device are low cost China brand mobile.
My Questions:
How can i make accuracy level near 99%. Is there any problem on my code architecture?
Does GPS accuracy depends on device configuration? if YES then what can I do for low configuration device?
How Uber, Go-JEK etc. ride sharing apps works for all device? Is they have extra coding for GPS only?
My application is for Bangladesh. Here internet is slow. Is it has negative impact on GPS accuracy?
Thanks in advance for this thread. And also sorry for bad english.
How can i make accuracy level near 99%. Is there any problem on my code architecture?
This is real life scenario. You cannot ensure that all the location providers will work as expected. You should ask for best available position.
a) Does GPS accuracy depends on device configuration?
YES. Some devices may have older GPS chipsets which can only track GPS signals (USA) since there are other positioning systems like Galileo (Europe), GLONASS (Russia), QZSS (Japan) and Beidou (China). The more the chipset support for these types the more chance you get to track more satellite hereby position fix. Also TTFF (time to first fix) depends on how many channels do the gps receiver has.
b) If YES then what can i do for low configuration device?
Since this is a hardware issue, you cannot do anything here. But other location sources can compensate the lack of GPS data such as AGPS (aided gps), wifi and cellular positioning. Also there are some paid options which provides a database to locate your device using wifi access points and cellids (they claim that they provide best solution on wifi but i m not sure as I dont use it. you can check it out http://combain.com). Wifi and cellid also depends on how many wifi access point and cell tower available around and how far they are (signal strength). If you need 50m accuracy, cellular positioning has nothing to do but wifi has a chance to get closer to this value.
Some study results from 2009 [3]
3G iPhone w/ A-GPS ~ 8 meters
3G iPhone w/ wifi ~ 74 meters
3G iPhone w/ Cellular positioning ~ 600 meters
How Uber, Go-JEK etc. ride sharing apps works for all device? Is they have extra coding for GPS only?
They may have specific Location strategies but it will based on using other sources during GPS outage.
My application is for Bangladesh. Here internet is slow. Is it has negative impact on GPS accuracy?
Other answers claims that internet is not related to GPS. Yes it is true it is not related to GPS but location. AGPS uses internet to fetch 3 types of data (Satellite signals, almanac and ephemeris) which assist GPS to provide position fix faster. If ephemeris and almanac are outdated or the device moved several hundred km from the previous position fix then it is called cold start and takes around 12-15min without AGPS.
Fused location provider already knows how to provide best solution with these configurations, so you should bless it.
References:
[1] http://gpssystems.net/agps/
[2] http://gpsinformation.net/main/almanac.txt
[3]
https://communityhealthmaps.nlm.nih.gov/2014/07/07/how-accurate-is-the-gps-on-my-smart-phone-part-2/
First, (and second)
How can I make accuracy level near 99%. Is there any problem on my code architecture?
Does GPS accuracy depends on device configuration? If YES then what can I do for low configuration device?
Both - device configuration and code architecture, are important here. If you are already at an 85% success rate, the code architecture is alright I think.
As far as GPS goes, line-of-sight is an important factor when it comes to device configurations and accuracy.
Although a low cost mobile could return an accurate location with a clear line-of-sight. You can try running 2 cycles more/waiting to attain higher accuracy.
In a worst case scenario and for what its worth, you can also try retrieving location using the LocationManager and GPS provider technique which works as a fallback in the 15% just to compare and ensure you are using the most accurate location you can get.
Location Strategies put it as
In most cases, you'll get better battery performance, as well as more
appropriate accuracy, by using the Location Services API.
How Uber, Go-JEK etc. ride sharing apps works for all device? Is they have extra coding for GPS only?
They do work but not always with highest of accuracy for locations received within the app. If there are any location hacks for us developers, we need to find them, maybe a 5th page google search result :) or benefit from the open source environment. For me, best practices and android repo links suffice. You have already followed posts like Receive location updates
My application is for Bangladesh. Here Internet is slow. Is it has negative impact on GPS accuracy?
No relation between Internet and LocationManager + GPS_PROVIDER

Geolocation with GPS very slow for an android app

I'm using intel xdk and cordova for an android app that uses geolocation this is the code that i use:
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geolocalizacion,error,{enableHighAccuracy:true, maximumAge:Infinity, timeout:100000});
} else {
handleNoGeolocation(false);
}
I don't want to use the 'google location service' because, if that option is disabled, some people can get lost trying to find it in settings, so i'm using enableHighAccuracy:true in order to use GPS.
However with that it takes so much time, almost a minute to call the success function 'geolocalizacion' when the app is used indoors. I know that GPS is better in outdoors (in that case it takes 5 or 7 seconds) but i think 1 minute is too much for indoors.
Am i doing something wrong?
Is there a way to make faster the geolocation with GPS?
or a way to activate the 'google location service' without the user doing anything?.
The GPS signals transmitted by GPS satellites are very weak if you are not located outside. Even if you are outside, weather conditions, tall buildings and other large metal structures can hide or degrade the GPS signal. In addition, the GPS receivers inside of your typical phone or tablet are very low grade receivers and antennas, they are not as capable as the more expensive dedicated GPS devices, due to compromises associated price and physical size.
You should really take a two prong approach: get an initial reading using the "coarse" geo reading, with the geo cache enabled. The coarse reading will use the wifi, network, GPS and cached readings and return it's best estimate based on the parameters you specify, usually within a very reasonable time frame.
Then, after you've established an approximate position (which can be very accurate, as #SeahawksRdaBest points out, if based on the current wifi), switch to the "fine" location setting to get an accurate position. This part of your app can run in the background so it doesn't interrupt the responsiveness of your app, and can then update the position information in your app as more accurate position data becomes available.
One thing to keep in mind, many users have the GPS turned off because it severely degrades battery life. If all your app needs is to "find a restaurant nearby" then the coarse location should be good enough, since you're probably more interested in placing the destination on the map. This will be much more battery friendly, and is one of the reasons that the geo settings on the more recent Android devices have changed to make it harder for an app to enable GPS programmatically.
I see you've added the intel-xdk tag, so you might want to checkout this little geolocation test app that I've put together at https://github.com/xmnboy/hello-cordova. It needs a little work but should help you with some experimentation between coarse and fine settings.
I think you can diversify your app a little.
For example if you are indoors and have a WiFi connection why not use that to triangulate your position? WiFi is highly accurate because theoretically it covers a small space so the phone would know exactly where it is and return a position quickly.(if done right in my experience usually <10 secs).
If a Wifi connection is not found(outdoors). You can always drop back to GPS to provide the coordinates. Plus Gps is "fastest" outside anyways.
Checkout these pages: Stackoverflow discussion. Location Manager Android.
If you want to get really fancy you can even use the Geocoder Android library to get Location addresses etc in human readable form.

How can I get rough location (country) forAndroid Tablets

I'm looking for a way to know the country-level location.
How to do it on a phone, or devices that have cellular network connectivity or GPS is clear. But what about devices that don't have that?
I know from Google Analytics that Google has that kind of location information,
How?
How can I get that information as well? Maybe from the play-store locale or something?
By "Tablets" I mean devices that have no GPS and no GSM / cellular network connection.
10x
Use the WiFi aproximated location. It checks your IP adress and tries to locate it geographically.
please see this or this.
a quick summary of the WiFi location method form one of the posted links:
How it works: Unless you opt out, your phone is periodically sending anonymous data to Google with, among other things, your last known location and any Wi-Fi network you were connected to at the time. The accumulated data builds on a database begun by traveling Google Streetview cars that recorded Wi-Fi networks available along their routes (the cars no longer do this).
When using this method, your application will ask for the COARSE LOCATION permission on installation.
Since there's no clear indication (at least none that I've found) whether or not Google estimates location based on IP as a last resort, my 'getCountry' logic would be as follows:
Location location = LocationClient.getLastLocation()
If (location == null) location = getLocationByIp()
where getLocationByIP() will use a publicly available, RESTful free web service such as http://freegeoip.net/
Open to suggestions here. If line 2 is redundant I will be happy to drop it.
Cheers
(Y)

How to accuratly find other Android users within a radius of 200ft ( How did Color do it?)

I'm working on a app which requires that a device with this app installed will automatically find other users within a maximum radius of 200ft (worst case scenario 300ft, but that's pushing it) and/or a minimum radius of 40ft.
Ive tried the obvious solution of using GPS and a MYSQL query that query's our location table for other users within the 200ft radius, but as you probably would guess this is not incredibly accurate and if the device uploads coordinates that are off by over 200ft the server will return a list of users that are not within proximity. While I would prefer to just get the app to work the way it was meant to I'd rather the server return no users than false positives.
I know there's probably no simple way to do it accurately, but what other options do I have? And how did Color manage to do it? With all the tech in the avg smartphone and all the location based apps this has to be possible to do.
200ft (60m) is no Problem for GPS. Usually GPS is below 10m.
You even have a location.getAccuracy() method which you should evaluate
Just use GPS as your only location source. do not use cell tower location provider, when you want accuracy < 60m.
Of course inside a building, when you are sitting at your desktop GPS will not work, or is off by 60m.
GPS needs a view to open sky not obstructed (by dense materials).
Take a look at this question:
how to get the most accurate location using GPS and AGPS with given time in android?
Basically it depends on the phone's GPS and the current environment. Besides that, there's probably nothing you can do to further boost the location accuracy other than using GPS.

Categories

Resources