How to get Android GPS location

Here’s your problem: int latitude = (int) (location.getLatitude()); int longitude = (int) (location.getLongitude()); Latitude and Longitude are double-values, because they represent the location in degrees. By casting them to int, you’re discarding everything behind the comma, which makes a big difference. See “Decimal Degrees – Wiki”

Algorithm to find all Latitude Longitude locations within a certain distance from a given Lat Lng location

Start by Comparing the distance between latitudes. Each degree of latitude is approximately 69 miles (111 kilometers) apart. The range varies (due to the earth’s slightly ellipsoid shape) from 68.703 miles (110.567 km) at the equator to 69.407 (111.699 km) at the poles. The distance between two locations will be equal or larger than the … Read more

Check if location services are enabled

Add the CLLocationManagerDelegate to your class inheritance and then you can make this check: Import CoreLocation Framework import CoreLocation Swift 1.x – 2.x version: if CLLocationManager.locationServicesEnabled() { switch CLLocationManager.authorizationStatus() { case .NotDetermined, .Restricted, .Denied: print(“No access”) case .AuthorizedAlways, .AuthorizedWhenInUse: print(“Access”) } } else { print(“Location services are not enabled”) } Swift 4.x version: if CLLocationManager.locationServicesEnabled() … Read more

Android Location listener in Service does not work until I reactivate WiFi/mobile network

You could use new location provider (FusedLocationProvider), which combines info from different location providers, so if your device has any possibility to obtain location, You’ll get know it. Of course, You should enable in preferences for your device to use location info by apps. Check developers.android.com for extended info about this provider. This is solution … Read more

How to measure GPS signal strength on Android?

Are you sure you mean signal strength vs. accuracy? What good is the signal strength? Since the GPS position is determined via many satellites, you don’t have “one” signal strength. So assuming that you really mean signal strength, you can get the GpsStatus via LocationManager.getGpsStatus(), and that gives you a list of satellites via getSatellites()‘, … Read more

iOS background application network access

Good point, according to the Apple documentation only the following usages are allowed in background and each service should be registered: audio—The app plays audible content to the user while in the background. (This content includes streaming audio or video content using AirPlay.) location—The app keeps users informed of their location, even while it is … Read more

How to find your current location with CoreLocation

You can find your location using CoreLocation like this: import CoreLocation: #import <CoreLocation/CoreLocation.h> Declare CLLocationManager: CLLocationManager *locationManager; Initialize the locationManager in viewDidLoad and create a function that can return the current location as an NSString: – (NSString *)deviceLocation { return [NSString stringWithFormat:@”latitude: %f longitude: %f”, locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude]; } – (void)viewDidLoad { locationManager = [[CLLocationManager alloc] … Read more