The app which i'm writing need to somehow detect if an android device is indoors or outdoors. My goal is to detect if the user left a certain building as soon as possible.
I tried to use the user location signals. I'm not initiating any GPS sampling since I don't want to waste too much battery power, so the only way to detect if a user left a building is to wait for him to be far enough from the place and then use location signals which were sampled by wifi or cell.
The problem is that it takes quite some time for me to detect that the user left the building.
I know that when a user is indoors, his GPS signal is weaker. Can I somehow use the GPS status to find out if the user is indoors or outdoors? Will it be wasteful as initiating a GPS location sample?
Thanks.
I don't think you can do what you want to do with the FusedLocationProvider as this uses WiFi and cell tower triangulation. You will need to use the LocationManager.
It is also difficult to detect if you're inside and as far as I know there is no definitive way of doing this. You can make informed guesses however.
In terms of detecting a "weak" GPS signal you have a few things you could check:
The number of satellites available to you. If a low number then you are either indoors or somewhere with poor satellite coverage.
The horizontal accuracy of a received GPS location. If this value is high it can be deemed as poor accuracy which could be because you're inside.
No location has been received for a period of time. This could be because you're inside.
Have you thought of doing other checks as well as GPS so if they're connected to WiFi it increases the likelihood of them being inside?
Hi I am working on a project which requires fetching of user's current coordinates and I am fetching it in high accuracy mode.
Ever since I started testing out this application in my device I have noticed that my money is getting deducted from my balance I am not sure why is it happening.
I currently dont have a data pack and my mobile data is turned of in my device but I am connected to wifi. Even if some application is using internet for some purpose it should make use of the my wifi connection right?
Can anyone please explain me why is my balance getting deducted (if you have faced similar issue) ? Is it really because of the fetching of location in high accuracy mode ?
Thanks.
Edit
I get this dialog box frequently:
GPS coordinates on a android device (or any device for that matter) is received in 2 ways.
From a GPS hardware that connects to your GPS Satellites
From your network, via the GPS location of the tower to which your SIM card is connected to.
The GPS hardware connects to multiple satellites and approximates your location to a point. And this location is the most accurate you can get. It consumes a lot more battery and decipates a lot more heat on the devices, since a lot of current is needed to read from the GPS satellites. This does not use the network at all. If your SIM card cannot make phone calls/and/or/data even then this location can be received.
Your network GPS also does similar, but it takes GPS coordinates of the towers closeby (to which the SIM card is connected to, and then approximates the location of your device. This GPS location (in comparison with the GPS hardware) calculates a less accurate. This consumes GPRS/3G data bandwidth and you will be charged for this.
Both the hardware are completely independent.
Now, some smart ass developers in Google have used sensors like compass, rotation, movement to develop something called AGPS, which takes the GPS location from the GPS hardware, and then uses network and sensor information to ensure that your location is known without use of too much power, and there by lesser heat decipation. This is called AGPS.
I'm developing an app which fuses location from various providers, hoping it will give a more accurate location than if I simply used the Google API. However, the choice of providers would depend on the phone being indoor or outdoor (Network vs GPS, for example).
What is the best way to detect if the device is indoor or outdoor? My first thought would be using the Light sensor, and maybe cell signal strength and WiFi (if there are WiFi networks near, it's likely the device is indoor), but I don't know which weight/confidence I should attribute to these sensors.
Edit: this is for my masters thesis, in which the goal is to get the location from the different providers (GPS, Network and Passive) in the Android API, and fuse them with a formula. Depending on whether the phone is indoor or outdoor, the several locations would have different weights. There would also be parameters like if battery life is priority or not (I haven't developed this formula yet).
Just subscribe to both providers and use location.getProvider() and location.getAccuracy() when new location arrives--to check if it's more/less accurate then previous.
I'd say your best bet is the GPS signal itself, because GPS rarely penetrates buildings.
In built up areas, you'll encompass WiFi networks all over the shop.
recently I checked location in galaxy tab by disabling GPS and wifi and the accuracy is around 50 to 65 meters(location is rural).
later I cleared the total cache memory of the maps app, and the device and when I checked the location under same scenario the accuracy is very bad it's around 1.2km to 2km.
-Now I activated the wifi and suddenly it came under 50meters, now when I disable it even then the location shown is around 60 meters accuracy.
Is there any way that we can find the approx location by only using mobile networks without using wifi and gps, as the device is gathering some info in to the cache and this helps when wifi and gps are disabled.
what I am asking is, can't the device use the mobile triangulation and get the accuracy around 50 meters than to depend on the cache of wifi and gps. where can we get this implementation source code of android.
PS: I want to disable wifi and gps because I want to mimic this functionality in hardware as adding wifi and gps modules is power hungry and costly.
In a large city, where the phone can receive a signal from several towers, then triangulation may well be fairly accurate. The only parameter that the phone can measure is signal strength, and from that infer a distance to each mast.
In a rural setting the phone may only have a signal from one mast. All that it can do then is to estimate the distance to the mast, place your position at the mast and calculate the accuracy based on that one signal strength.
I want to access my current location in my application in android. Initially I did that with WIFI and CELL TOWER in indoor. I used GPS to access locations at outdoor. The location accessed via GPS is accurate but via WIFI is far away from the actual spot. Can anyone help me regarding this issue.
The GPS system determines your position by connecting to and timing the responses from 4 different satellites. Due to this, it requires a clear view of the sky, and doesn't work indoors and underground. It also allows it to be very accurate.
On the other hand, WiFi positioning uses a table compiled by Google and other companies and organizations that has anonymously collected data about wifi hotspots and GPS positions of devices connected to those. This is much less accurate than GPS.
Cell network positioning uses the Triangulation technique, which uses one or more cell phone towers to determine the approximate location of the device. This method is explained very well here.
Location is a crapshoot.
Generally, GPS is accurate enough to get you to right address - and even that can't be counted on. Wifi to the right neighborhood, and cell tower the right zip code (or neighboring one). If you need to locate people within specific buildings, use one of the "indoor positioning systems". There are a couple available for android but you need to prepare the buildings.
There is a lot of nonsense about triangulation posted in this thread.
Old time surveyors and radio direction finders used triangulation. GPS, cell tower, and wifi do not use triangulation; they use Trilateration (or worse mere proximity). Triangulation is the determination of position by the measurement of angles (minimum of not three but two angle measurements and one baseline distance make a triangle). Trilateration or multilateration is the determination of position by measurement of distance which in this case is derived from time of travel (GPS, some cell network based location systems) or received signal strength (cell tower, wifi). And often you don't have at least three towers or routers to properly trilaterate off of. You can get some position data from two towers but it has more ambiguity as it doesn't know which side of the line between the two towers you are on. These two alternative locations can potentially be almost as far apart as the cell towers themselves. And if you only have one, then you can only narrow the position down to the working area around the tower (or one or two sectors of that radius based on which of the three antenna arrays sees the cell phone).
Cell towers may be as close as 1/4 mile in urban areas, 1-2 miles in suburban, and as much as 22 miles apart (GSM timing limit) in rural areas (particularly when located on mountain tops). So the nearest cell tower might be dead on accurate if you happen to be standing at the base of the tower but in practice it is likely to be off by 1/8mile to 22miles. Yet a woman was falsely convicted of murder and incarcerated because this method ["pinpointed"][1] her location - give or take 22 miles.
If we have several cell towers in range we could trilaterate the position but the accuracy will be limited by the crudeness of the signal strength based interpolation and the very long baseline between towers. Is the signal weaker because of more distance or is it weaker because it had to go through walls, trees, and shrubs and had to bend around buildings, trees, and shrubs? Was the signal reflected off other objects? Or because the transmit signal strength was lower to start with?
For WiFi, the routers are frequently located at each house and business. So they may be 50 feet from one another. And there is a very good chance that you are located very close to the wifi you are using or nearest. WiFi location may not work at all in many areas because the buildings are so spread out.
And WiFi and cell tower based location depend on having a database of tower and wifi router positions which is often incomplete, approximate, and sometimes wildly inaccurate (consider what happens when you buy a wifi router at goodwill and leave the SSID the same or move a router). Google gets this data by driving streetview vans around collecting data and by grabbing data from user's phone cellular radios and GPS.
[Skyhook wifi location][2] accuracy estimates: 1 Wifi: 700 ft, 3-4Wifi: 150ft, dense urban, more wifi: 50ft. Google
GPS has much larger distances between satellites and users compared to wifi and cell based systems but is a much more sophisticated system engineered from the ground up to be a locator system and using sophisticated timing measurements. It works almost anywhere on earth but can have problems with heavy tree canopy, dense tall buildings (skyscrapers), or being inside buildings. And with inferior devices that don't have a GPS chip. Or with the GPS chip being turned off because it consumes significant amounts of battery power. Most devices today have wifi even if they don't have GPS or Cellular.
In approximate order from worst to best (may vary depending on location):
nearest cell tower - off by up to 22miles but often within a mile.
This is the data the government can usually get from cell provider records.
cell tower trilateration (signal strength) done at tower. Rare.
The government/cell company can do this if they know they know in
advance that they need to but can't do it retroactively.
cell tower trilateration (signal strength) done at phone.
The phone has a list of "neighbor cells" and their signal strength.
Google could use this.
Cell tower trilateration using network based timing.
Strongest wifi
Wifi trilateration by signal strength done at phone.
GNSS (GPS (US), GLONASS (Russia), Galileo or Beidou/COMPASS (China), IRNSS (India), QZSS (Japan)). Accuracy of around 50ft
Differential GNSS (A system such as WAAS is used to correct) Accuracy around 10ft.
Emerging in-building location systems (using wifi routers or bluetooth low energy beacons with exact positions known and calibration data collected inside the building or potentially time of arrival based systems).
Survey quality GNSS - not found in phones. Accuracy around 3ft.
Accuracy of each technique can vary a lot and rather than being accurate to a stated distance, it is a probabilistic distribution.
For one dedicated outdoor (trail) GPS receiver I own combined with an external antenna, someone [measured][3] that 10% of the time, the accuracy was about 1m, 50% of the time the accuracy was about 2.9m, 95% of the time the accuracy was within 6.9m, and 99% of the time it was within 10.1m. And 1% of the time, it is just embarassing. So most of the time, it can locate you to about the size of a suburban lot. And on average it is about 10ft. A cell phone might use a newer chip but it also has a much lousier antenna.
Also, within a building you can use NFC tags, QR codes, 2D barcodes, and bluetooth beacons to designate specific locations such as rooms, workstations, businesses, departments, check out lines, etc.
[1]: https://www.techdirt.com/articles/20140908/04435128452/turns-out-cell-phone-location-data-is-not-even-close-to-accurate-everyone-falls-it.shtml Turns out cell phone location data is not even close to accurate
[2]: Howardforums thread 1383415
[3]: http://www.leb.esalq.usp.br/disciplinas/Molin/leb447/Arquivos/GNSS/ArtigoAcuraciaGPSsemAutor.pdf GPS HORIZONTAL POSITION ACCURACY
The Wi-Fi and cell tower combine to give you what is called COARSE accuracy in Android. By default this is stated as an inaccurate result and is only approximation of your location. This method gives a faster result and uses less power, and therefore gives an approximate result.
The GPS result is called FINE accuracy in Android, naturally because its result is finer and more correct when you use the maps. This comes with the fall back of taking a longer time to calculate, as well as using more battery power.
I would suggest you use the getBestProvider method to determine which provider is the best at any given time and it will give you the most possible accurate location. Unfortunately if it uses any of the coarse accuracy sources, you will have to bear with some approximately inaccurate results
GPS uses satellite triangulation method.
WIFI/CELL just uses tower location, and assumes you are somewhere around in its area/range.