Before explaining my problem, I ask that you please bear with me. I realize this question has been asked before, but I went through all S.O. posts related to this, and none of them were really able to solve my problem. I will try to be as accurate as possible:
I am simply trying to get my user's location. I have requested the appropriate permissions on the Manifest:
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
And I have made the call to request location in two different ways:
//Get Location
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
try {
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 360,
10, mLocationListener);
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 360,
10, mLocationListener);
} catch (SecurityException e) {
e.printStackTrace();
}
Then, I instantiate my listener as such:
private final LocationListener mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
Log.d("THIS IS NOT BEING CALLED", "GOT LOCATION");
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
I also tried making that listener into a custom class "MyLocationListener" which I try to instantiate in my onCreate() method on my activity.
Furthermore, I checked that my GPS was on, both by checking settings and by using the Maps app.
None of this has worked for me. Is there anything else that I might be missing?
Thanks in advance for your help.