Geolocation
What is Geolocation
Geolocation means, finding the current position of the user. This information can be used in several fields such as;
- Geotagging Photographs
- Displaying Maps
- Finding Directions
- Applications like Zomato needs them, according to the location they will show respected shops.
Ways of Geolocation
Network - Based Geolocation: Mobile phones in Urban area, receives signal from the Mobile towers and Relative strengths. We can get the physical location of Towers and estimate the location of mobile device. The results in this type are very variable and not accurate. Data gathered from this is known as Coarse location.
GPS: Global Positioning System. GPS has 24 satellites orbiting the planet, any mobile device, at any time, at any place can receive signals from at least 4 of them. Without any obstruction. This is enough for determining the location of user with accuracy. Data gathered from this type is known as Fine location.
In this case, a device must have GPS receiver, which almost every mobile has nowadays. One limitation is that, GPS doesn't perform well indoors. This problem is solved using A-GPS.
Charges
Network methods incurs some kind of charges, because they are communicating with mobile towers. But, the GPS method is completely free.
Usages of Geolocation
- Finding user's current location at unknown place.
- Providing Direction information.
- Location aware apps. For example, Restaurants near me etc.
- Geotagging, currently being used in many organization as attendance system
Before using GPS in application, one must check that; if device has GPS & Network support or not.
LocationManager locationManager = getSystemService(Context.LOCATION_SERVICE);
Boolean gps = locationManager.isProviderAvailable(LocationManager.GPS_PROVIDER);
Getting the current location of the user, We implement LocationListener
class when working with Location related task, and override method onLocationChanged
class MyLocation implements LocationListener{
@override
public void onLocationChanged(final Location loc){
double lat = loc.getLatitude();
double long = loc.getLongitude();
//accuracy and provider.
}
}