Why aren't you using the LocationManager class?
try {
locationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
// getting network status
boolean isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isNetworkEnabled) {
// no network provider is enabled
} else {
// The minimum distance to change Updates in meters
long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
// Get location from Network Provider
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
Further information can be found here: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/
LocationManager.NETWORK_PROVIDER
This provider determines location based on availability of cell tower
and WiFi access points. Results are retrieved by means of a network
lookup.
Docs:
https://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER