Google maps Android API getting wifi location - android

So I am working on this app that will get the location of a wifi hotspot by just detecting it using the sensor wifi of the phone (The phone is not actually connecting to the hotspot wifi, it just detect).
I was doing some preliminary research before start developing the app, and it seems that the Google Geolocation API will do the work for me. However, it is not free (at least what I understood after reading through the API). I had checked other apps that detects wifi hotspot, and I am just wondering if those apps have their own database with all the wifi hotspot information (SSID, location coordinates, etc) so when the wifi sensor detects a wifi hotspot, it will lookup the database and get the information such as location.
Also, I was mentioned by a colleague that Google Maps also stores wifi info. Is is true? Cause I couldn't find any info about that.

Android has multiple LocationProviders, including:
LocationManager.GPS_PROVIDER : get position using GPS
LocationManager.NETWORK_PROVIDER : get position using Wifi, cell network, etc.
LocationManager.PASSIVE_PROVIDER: get position using data provided by already running providers. This allows several apps to share geolocation information)
You don't have to pay anything to use NETWORK_PROVIDER
Some providers might not be present on all devices, depending on phone model and android version.
Providers have different characteristics: NETWORK is fast but not always precise enough, GPS is precise but slow and battery intensive, etc. The best strategy is to request location from several providers, and cancel pending request as soon as you get a location that is good enough depending on your criteria (precision, response time, etc.)
I found this article by Reto Meier quite useful to wrap my head around geolocation on Android

Related

mobile positioning in google maps using only internet

I used an android smartphone in the following situation:
without SIM-Card
connected to a WLAN
located in an indoor environment (GPS does not work)
located somewhere other than the address probabely set in google account
for positioning in Google-Maps App. The result was roughly correct (about 15 meters error).
There is no GPS signals to get position.
Thre is no SIM-Card. So using Cell ID is impossible.
It means the only resource from which my position is achieved is internet. Could anybody explain to me (while I couldn't find anything in internet) how this is possible?
Google gathers information on the SSID of WiFi hotspots. They drive around with cars gathering street views for their maps and other information like the location of WiFi hotspotes. They store it in a data base somewhere and when you ask for your location it will find out the SSIDs of every WiFi hotspote around you and then give a rough estimate based on signal strength and other information.
Google might use people's cell phones to gather WiFi SSID information as well I am not really sure about that though. I think this because there are setting in most android phones asking to help Google for accuracy using WiFi...
Other sites use public ISP information obtained by IP address but this is not as reliable as it gives the location of your ISP (Internet Service Provider).
Here is a site where many people are discussing this topic.
Here is a site that teaches how Google finds location data through SSID
Here is a site that teaches how geolocation software finds ISP location
Google, apart from other ways, uses SSID of the nearby networks to get your position. AFAIR there was a big concern about Google Street View Cars scanning for wifi networks, recording SSIDs for location purposes. If that SSID is not registered, they probably use some kind of IP location service, based on network provider ip address pool.
See Google maps Android API getting wifi location for more details about getting that information from Android.
Android may use wifi and sensors in order to get your position. The more wifi routers around - the more accurate your position.

Disabling Location permission on Android 6 seems to affect WiFi parameter queries

I have an Android application that accesses the device's location and then queries the WiFi parameters. Everything typically runs smoothly.
If I turn off the Location permission for the app (as I can do in Android 6) I no longer get the device's location (as is expected). However, I also get a modified WiFiInfo object when I try to query the WiFi parameters. In particular:
getScanResults() normally lists all of the networks available, but with Location turned off it only contains the network the device is connected to.
If I look at the capabilities of the network that is found, the string is empty. Normally it contains information such as the wireless encryption information.
Has anyone else seen this? I've verified it using the same code with the Location permission turned on/off on 2 different devices. Any idea on what's happening?
Update: On further review, I was wrong when I said that getScanResults() returns information about the AP that the device us connected to. It in fact returns an empty list. This would support the idea that Google doesn't want us to have any information about the local APs if Location permission is denied.
WiFi-based location is basically a lookup of WiFi access point information in a giant database of known APs and locations to discover where a device is. This is what services such as Google, SkyHook, and Apple use when you enable WiFi or network location.
I suspect Google is trying to prevent an application from accessing information from which location can be derived when location is disabled. They have previously blocked access to Google Play location services when location is disabled, but this does not prevent a device from doing a scan, collecting the same data that would be sent to Google, and sending this data to a different service to discover location.

Is there an alternative to Location Client (Google Play API)?

I work on an app that uses location data, and it needs to work in China. Android devices sold here largely don't have Google Play API installed at all and the only way is to root the phone to install it. So I'm stuck with LocationManager which works far worse than LocationClient (part of Google Play API).
My issue is that LocationManager, when reading from GPS_PROVIDER, frequently cannot connect to enough satellites (in China) and there's occasional significant time gap between fixes. When reading from NETWORK_PROVIDER, I can get more frequent fixes, however accuracy ranges from 30 to 500. Nowhere near LocationClient API quality.
The app is supposed to monitor your movement through streets frequently, eg. update every second (high battery use, not a problem to my client) and do something when you reach certain locations.
If I use Google Play API and LocationClient, it's really working well. But that's only on Nexus4 or some non-Chinese Android device.
I'm asking if anyone know a library that can give better results than straight forward use of LocationManager, or a solution how to use LocationManager to improve results?
GPS isn't working well likely due to lack of required GPS metadata (ephemeris and almanac data), or due to slow acquisition of this metadata. For the latter case, in most countries GPS ephemeris and almanac data is available through network sources.
If not, the GPS chip has to download that from the satellites which can take 5-20 mins (the fastest time being when the initial data stream provided enough info for the GPS chip to acquire a lock). I am not familiar with the availability of this data in China through network sources, but it sounds like it is not widely available from what your are experiencing. (Keywords to google for more info: SUPL, ephemeris, alamanac).
When GPS is not available or slow to get a lock, network geolocation is the fallback, which uses wifi points and cell towers to triangulate a position. This requires an internet service for the device to send the APs + towers it sees, and the service sends back a location.
Accuracy levels of 30 to 500 meters are quite good for this.
(BTW, a network geolocation position is also used to 'seed' the GPS chip to help it to get a faster lock)
Network geolocation on Android is typically provided by a google web service, but the phone can be configured to use other providers by carriers.
You can avoid using Google (Google Play or Google's network geolocation server) or the built-in network location service by trying Mozilla's free-for-use network geolocation service:
https://location.services.mozilla.com/
You need to request an API key: https://location.services.mozilla.com/api
For a code sample: this app both contributes data and is a client for the service: https://github.com/mozilla/MozStumbler
I doubt this will get better network geolocation accuracy for the area you are in, since you are already getting good results, but perhaps it is worth investigating.

Android Network provider, internet needed?

I'm using network provider for location updates. Do I need to to have internet on my cell?
Here is my code
LocationMngr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, inteval, 0, this);
I'm getting confused of seeing other's Answer. Then I searched a lot and get some idea about that. While searching only, I have learnt about new concept of A-GPS. I would like to share those things with you.
There are three location providers.
1. GPS Provider
2. Network Provider (AGPS, CellID, WiFi MACID)
3. Passive Provider.
Note: I refer this from this site. As you asked question related to network provider, I will share regarding to that.
Network provider, name itself says that it needs network connection. Refer this article. It need network or WIFI connection to proceed.
A-GPS
GPS on cell phones is a bit more murky. In general, it won't cost you anything to turn on the GPS in your cell phone, but when you get a location it usually involves the cell phone company in order to get it quickly with little signal, as well as get a location when the satellites aren't visible (since the gov't requires a fix even if the satellites aren't visible for emergency 911 purposes). It uses up some cellular bandwidth. This also means that for phones without a regular GPS receiver, you cannot use the GPS at all if you don't have cell phone service.
For this reason most cell phone companies have the GPS in the phone turned off except for emergency calls and for services they sell you (such as directions).
This particular kind of GPS is called Assisted GPS (AGPS).
Note: Even if phone supports it, and network does not then this does not work
No need for Internet for retrieving location (GPS or Network provider). Using Internet can speed up the process and giving you more accurate locations (when dealing with Network provider).
No, the GPS sensors are independent of connections to the internet, so you don't need to worry about internet connectivity if you just want to get your location via GPS. I have a Nexus 10 which has a GPS sensor, and it works just fine when I'm roaming without internet connectivitiy.
no you don't need internet conection.but in some roms it may be some errors in conection.
in gps module you don't need internet but some ways you can use wifi for more performance in.such as google navigation services.

GPS clarification

I'd just like to ask for some clarifications regarding the GPS functionalities of android phones. When an application activates the GPS of a phone, will the phone need to be on a data plan or should activate the data traffic ( Settings > Wireless & Network settings > Mobile Networks > Data Traffic) for the GPS to get the phone's coordinates?
From Wikipdeia
The Global Positioning System (GPS) is a space-based satellite
navigation system that provides location and time information in all
weather, anywhere on or near the Earth, where there is an unobstructed
line of sight to four or more GPS satellites. It is maintained by the
United States government and is freely accessible to anyone with a GPS
receiver.
If you talk specifically about GPS then it's nothing to do with the data plan or even with your service provider. GPS is totally independent of it. Think of a stand alone GPS receiver device e.g. Garmin GPS 10. It just connects to your laptop through Bluetooth (some with USB cable) and start sending GPS data to it. These devices normally output GPS data in NMEA format. Modern phones includes same sort GPS receiver circuit integrated in them. The thing different here is that these phones consumes GPS data for internally available rather than directly outputting in raw form. That's how you get GPS location information in iPhone and Android smart phones. On the other hand think of GPS navigation devices we use in our cars e.g. Garmin nuvi. It shows the location of car on the integrated maps. There is no sim card in it. Same is with GPS fitness watches.
A good question here is How GPS calculates the location? Best explanation I found is on HowStuffWorks. It's very easy and very well explained. Apart form GPS there are other positioning systems in the world, though GPS is oldest and most widely used. After GPS from US, there is GLONASS from Russia. Some phones support GLONASS too e.g. iPhone 4S and Samsung Galaxy S III. Well there is nothing to worry for developers though. These phones internally use GPS and GLONASS to have high positional accuracy and gives the location in same way.
Other positioning systems includes Compass from China and Galileo. These are under development at the moment. For complete list check this Wikipedia article.
Edit: Location can be also be determined by mobile networks and wifi networks. For example Google Latitude tells your approximate location if you are connected with wifi and even you don't have GPS device connected. In case of location determination by mobile networks, the service provider may charge for location. Normally locations determined by mobile and wifi networks are not very accurate but location can be determined indoors which is a very big problem of GPS location calculation.
Hopefully it will help how things are working.
Cheers! :)
Atleast in India I can access use the GPS whenever I can see the sky, no data plan is required for me.
I haven't tried it on Android but it should be possible to get GPS co-ordinates without a data plan. My iPhone gets GPS locations even when out of reception, I can't see why android would be any different.

Categories

Resources