my question title is kind of self explanatory.
When I want to get my current location, for the first time(after phone start up), I have to be connected to the internet.
After getting the location once, my app no longer needs the internet connection and the update happens just fine.
At first I thought there was something missing in my code, but I tried the in-build maps application, and it also couldn't get my location until I enabled data transfer.
This seems really strange to me, if I can get coordinates without net connectivity after the first coordinate is aquired, why do I need it in the first place?
So I was wondering 2 things,
1 - is there a work around to let me get my first Location without being connected
and
2 - if there is no work around is it practical to ask the user to enable it? I'm not 100% on this but I'm pretty sure I cant enable data programatically.
Would like to hear your opinions.
Thanks :)
Android devices use what's called aGPS - the a stands for assisted. The most basic I've seen it explained is that certain information has to be downloaded and a general, broad location identified in order to allow the GPS sensor to know where to look for the satellites. Once it has the information, it can find the GPS satellites, and is fine. There is no way for your app to get around that fact, I'm afraid.
Have you defined <uses-permission android:name="android.permission.INTERNET" /> in AndroidManifest.xml
If yes then check you internet connection:
Or
Check My Answer Here: Get current latitude and longtitude
Related
I am looking to get device's location every 1 minute. I noticed the incorrect location of some devices.
With S7500 the correct location is found after 3-4 minutes sometimes or more, with HUAWEI Y530-U00 the correct location if found instantly. I used the example https://github.com/googlesamples/android-play-location/tree/master/LocationUpdates.
S7500 is not very powerful so I thought about a device limitation but it find location after a while. Maybe the code use only phone cell or internet instead of GPS and it makes location difficult.
Is there a way to improve this?
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.
I'm attempting to get my phone to update the assisted GPS info.
I've followed the instructions outlined in question
Android: How to reset and download A-GPS data?
This seems to tell GPS to remove the "almanac" SO I'll assume the next time my handheld attempts to connect it will also attempt to get the almanac.
This is not really what I'm looking for, because (at least according to wikipedia) GPS take about 12.5 minutes to get the new almanac. It does indeed feel that long, though I've not timed it. Even 5 minutes seems like a long wait when I'm ready to start a run.
When i was skulking about, I came across "GPS Status & Toolbox." This app downloads the data via wifi or 3g. It's lightning fast and perfectly suited to my needs.
Beyond setting clearing the data, I'm wondering if anyone knows how they accomplish the insertion of the data?
You are confusing two different methods to obtain the almanac necessary for GPS to compute user locations:
Receive and decode the almanac directly from the GPS satellite signal, which is broadcast in its navigation message. This is the part that takes 12.5 minutes (i.e. to download the entire almanac from scratch. In practice, this is only needed after a "cold start" of the GPS receiver). In general, a GPS receiver does not require the almanac to obtain a position solution. Instead it performs a so-called sky search to determine which satellite signals are present.
Receive the almanac from an alternative network (e.g. cellular network) that is dedicated to providing such information. This method is also known as Assisted-GPS (A-GPS). This is the method that smartphone-based receivers will typically use, as it is much faster.
The answer you cited concerns the second method, i.e. telling the system to retrieve an updated almanac from a server.
For those who came to this page due to the headline "Is there a way to download the GPS almanac?" and who want to actually see how the almanac data actually looks, you can always download the current almanac data from the US Navigation Center.
First you must distinguish between
almanach
epheremides
preditced ephermides model
The almanach contains the rough satellite curves, valid for "long" time.
Once received the chip does not need to wait for it each time.
The epheremides contains the detailed satellite orbit modell. They are valid a short time.
The predicted ephermides is a ephermides modell that can predict up to two weeks.
It has to be downloaded form a server, this data is not available through GPS communication. And might be proprietary to specific GPS chip manufacturer.
You can set both the almanach and the epheremides to the chip, via (custom) NMEA or usually the GPS chips properietary binary messages.
How this can be done via a hack on android i cannot tell you.
I expect that android OS does this automatcially without need to have a GPS Status Toolbox
I hope this is an appropriate question for this group. It is not strictly speaking a programming question unless I end up writing my own NEMA listener instead of the location listener but that would mean a start over on a lot of code. I have written a GPS based application and want to use an external GPS at 5HZ. I have been searching for a couple of hours on Google and this forum with no luck for answers to my problem.
I have been using Android apps to talk to the external GPS. I can get 5Hz with Bluetooth GPS Provider or GPS Mouse but they both have time errors of about 18 seconds (slow). I can get accurate time with Bluetooth GPS but only at 1Hz. I have checked the raw NEMA output of the Qstarz unit and it is correct at both 1Hz and 5Hz.
I am using the standard location listener and everything in the program is working fine. I just want to get 5Hz data and accurate GPS time. At first I thought it was a GPS Leap Second issue but the NEMA data is correct with real time. I use WWV to find real time.
Try:
http://sourceforge.net/projects/bluegps4droid/files/
This app updates mock location at the frequency of the source GPS.
I've been trying to get this to work for a few days without success. Basically, I'm writing a small test app to make the phone report it's position as somewhere else using addTestProvider and setTestProviderLocation etc. Basically it looks fine and appears to report its location as having changed, however Google Maps etc. seems to still be querying the real GPS provider. Does anyone have any ideas how to get around this?
This isn't an app that will actually be used for anything, it's just really to satisfy my own curiosity and gain an understanding.
Thanks in advance.
You need to first allow your application to use Mock locations by adding the following to the manifest xml:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
On your phone, ensure 'Mock Locations' are enabled by selecting the “Allow mock locations” option under the Settings -> Applications -> Development menu.
And then use a mock location provider to give fake locations (e.g. by reading data off a file/db)
Alternatively you can telnet into your phone and mock the location (again you need permission and mock locations enabled on your phone):
$ telnet localhost 5554
Android Console: type 'help' for a list of commands
OK
geo fix -82.411629 28.054553
OK