Using the getAccuracy wrong - java

I'm building a location based application and I would like to avoid from this kind of location: "Tel Aviv, Tel Aviv, Israel" which is very not accurate.
I use the following condition before using a location:
if(!(this.location == null || this.location.getAccuracy() > 700))
// use the location
But I keep getting this locations (Tel Aviv, Tel Aviv, Israel), and Tel Aviv is not small enough to pass this condition.
I'm missing something? What's wrong?

You haven't specified a couple of parameters involved but I'll give it a try.
The exact Location parameters depend on the source of that particular Location, i.e. how it was obtained and using what geolocation source(s). For example:
If you use GPS, the Location will have reliable accuracy values.
If you use cellular network radio stations (BTS), the accuracy you'll receive will be limited to the database of BTS around the world, their location and range.
If you use Wi-Fi networks and their reported signal strength, the accuracy will depend on the quality of the database of the Wi-Fi networks. Unfortunately such databases are not cheap to maintain and create. For example Google buys such databases and uses Google Street View cars for scanning such networks.
If you use localization based on public IP address, your accuracy will be limited to a town, because that is the most accurate information contained in IANA IP address space registry. Also, it can be fooled by using a proxy servers.
The accuracy you'll receive from a location service represents a distance (in meters) from the reported location in which the device is likely to be in the moment the location was obtained.
So (if I understand your question correctly), I presume your using a low-accuracy method of obtaining current device location. You simply must switch to a source of Location with greater accuracy.
Please also note that the location-acquiring method (i.e. the service used to find the location as described above) used by the location service might actually not be able to provide accuracy for returned Location. To understand what I mean by that consider a following scenario and their two outcomes - note that they both come from the same locating method based on Wi-Fi networks:
You are in range of several Wi-Fi networks. You ask the location service about device location. All Wi-Fi networks in range happen to be in location service DB. The location service is thus able to get your location with decent accuracy.
You are in range of several Wi-Fi networks. However, none of them happens to be well known to location service in that their origin (town) is known, but their exact location and range is not known. In that case the location service is able to tell you which country/town you are in, but has no idea on your precise location. In turn, location service can give you a location with no accuracy.
You must make yourself prepared for such an occasion by testing if the accuracy is available at all. You can do this by issuing Location.hasAccuracy(). If the returned value is false, you can't call Location.getAccuracy() (actually you can, but beware - it'll return 0!). So, your condition should be more like:
if (this.location != null && this.location.hasAccuracy() && this.location.getAccuracy() < 700) {
// do something
}

Related

Track the exact location of IP address

I am trying to create an app to find the exact location of IP address. I did some research on IP addresses and many more. But whenever I try to locate an IP address it provides the location of Internet Service Provider. I want to track the exact geolocation or long & lat of that place. So can anyone help me out to let me know how to find the geolocation of Dynamic IP address
The information upon which such a service might (hypothetically) be based is not available. Ergo, the ISP level information is about as good as you are likely to get for wired IP addresses.
#salocinix wrote:
"The exact position of an end-user's IP is only store at the ISP database and is normally not given away."
The second part is definitely true. They don't and shouldn't give away details about their customers' physical locations. There are obvious privacy concerns with doing that.
But it is quite possible that the ISP doesn't store the customer's physical location at all. Certainly, there is no need for them to store it in the form of longitude and latitude. Whether they need to store it depends on who owns the wires. In Australia for instance, many customers' ISPs don't own the wires that carry the traffic to the customers' dwelling. In that case, the ISP (in theory) only needs to know the billing address for the customer. And then there is the case of ISPs who sell internet connectivity for mobile devices ... where the physical location of a given IP address can change on a minute-by-minute basis.
... just asking because google maps shows the exact location of my PC on map how does it work
The PC is most likely geolocating itself via a combination of GPS and triangulation of local wireless base stations.
The exact position of an end-user's IP is only store at the ISP database and is normally not given away by the IS-provider. Try out the following link, you'll not achieve much more precision.
http://www.iplocation.net/index.php
I urge you to read the following thread on NANOG which was written by Fred Baker of Cisco, author of 50 network related RFC's.
Well, let me ask you you think 171.70.120.60 is. I'll give you a hint;
at this instant, there are 72 of us.
Here's another question. Whom would you suspect 171.71.241.89 is? At
this point in time, I am in Barcelona; if I were home, that would be my
address as you would see it, but my address as I would see it would be
in 10.32.244.216/29. There might be several hundred people you would
see using 171.71.241.89;
Geolocating is gimmicky at best.

apps, remote sripts and security/obfuscation

I will construct a fictional app in order to construct my question.
I write a kind of treasure hunt app where the user gets a prize if they visit several locations around town. In effect the app would get their current lat/lon and check its proximity to the list of "treasure locations", if they are within 10 meters of any treasure location they get a notification.
The app will then do a http post to a remote script which basically inserts into a database. The post parameters will be uuid of device and the location they visited.
An attacker could easily watch wireshark and get the name of the script along with the parameters. They could go further, decompile the apk and get other things such as any hashing/obfuscation. They could then just use curl to post willynilly as they pleased and the game would be ruined for non-cheaters. This is a problem have never had to really address since in all the apps I have written there is always data which isnt sensitive and I dont mind it being exposed to the public.
What do I do?
The best think you could do is to send the data in a secure manner. Using HTTPS would be a much better choice, regardless of method. This effectively prevents eavesdroppers, it is the fundamental technology behind any secure communication on the internet.
Aside from the protocol to communicate with the server, there are still insecurities. Essentially, there are three methods that could work to overcome these.
The location of the player could be sent to the server at some periodic interval. The server responds back if they are close enough to one of the areas. Perhaps the server could include enough smarts to know that it takes time to get from point A to point B.
A single location could be sent at a time to the app. The track of the user could also be uploaded, to verify that the location is correct.
The locations could be sent through a one way function to the program. The real answer could be then sent to the server. The problem with this is that the exact location would need to be discovered in order for the same hash to result back. However, as GPS coordinates tend to only be accurate to a few meters, and don't tend to give insignificant digits, then multiple values could be tested near the current location. The one-way function would have to require some time to calculate in an effective manner, as otherwise it would be trivial for a bad guy to simply test every square meter in the city to figure out what would work.
The best method from a security standpoint would be the first, as at no time does the application know where it is supposed to go, until it reaches that location. Of course, this pings the server a large number of times needlessly.

Concept Behind Geographical Position Retrieving

For getting Geographical Position of a user we have so many API's can any one tell me what is the concept behind this? How these api's can detect the geographical co ordinates of a user.
Please Explain
Thanks and Regards,
Sunny.
This depends entirely upon the API.
Some APIs are dependent on a piece of hardware (such as a smartphone) that utilizes an inbuilt GPS.
Other APIs attempt to use WiFi and/or IP data to attempt a crude calculation for your location. Google's MyLocation feature is an example of this, it uses information gathered by your browser to estimate your location. Here's a link to an article discussing Google's use of WiFi/IP to calculate users positions:
Google MyLocation
Others such as Google, Bing, or ESRI map based APIs allow you to query their maps to receive coordinate information about a specific address that the user inputs. If you already know users are going to access your application from a relatively small geographic area, you can submit the query on their behalf and use it to create a map based on this area (ie: a city, college campus, etc...), or to obtain a set of geographic coordinates when all you have are the addresses (ie: a list of restaurants, apartments, etc...).
Any particular API that you are talking about?
As far as I know, there are 2 ways in general
GPS-enabled devices: So the device itself that know its own geolocation through it's GPS system
Through who you are connected to: a) If you are mobile device, they can pinpoint your location through figuring out the towers you are connected to, or b) If you are on an internet / wi-fi connection, it can be figured out from there.
http://www.ehow.com/how-does_4965061_gps-work-mobile-phones.html
or
How does GPS in a mobile phone work exactly?

Get the list of WiFi access points in J2ME

To the developers under J2ME.
Is it possible to get a list of all available WiFi points in the moment in Java? Class IAPInfo gives me just a list of available network connections, where there are different internet and other connections, such as internet.mts.ru etc. and besides there is the connection 'Search for WLAN' (like so) and there are no access points themselves there. Already seen examples of a list of WiFi points in C + + for Symbian, but I'm writing in Java. I need a list of access points to define an exact position of mobile phone. I know about cellular communications and GPS, but I also need WiFi.
You can't get a list directly from J2ME.
A better idea is to use JSR 179's LocationProvider which will use any means at its disposal to provide you with a location reading (this may or may not include WIFI locating).

j2ME setLocationListener()

I'm programming a GPS tracking system using the Motorola i335 running on Sprint's IDEN network. I'm using the javax.microedition.location api to find the GPS coordinates. To set up the updating, you use the [setLocationListener][1] method. I originally tried passing (listener,2,1,1). However there were too many invalid locations being received (where the GPS could not get the fix in the specified time), so I changed the parameters to (listener, 20, 20, 1). Now the system barely throws any invalid locations. My goal is to get the fastest number of updates that are realistic. Have any of you found a happy medium for parameters of this method?
[1]: http://www-users.cs.umn.edu/~czhou/docs/jsr179/lapi/javax/microedition/location/LocationProvider.html#setLocationListener(javax.microedition.location.LocationListener, int, int, int)
I'd rather implement a verisimilitude check to avoid invalid location data.
Checking the provider state for availability and comparing the last returned lat/lon values should do the trick.

Categories