The application will run correctly on my real device just fine but as running on the emulator, it immediately crashes and I receive an error message noting that the GPS coordinates are null. Even after opening DDMS, running the application, then sending coordinates and attempting the login, where the onCreate method will be called looking for GPS, it still notes null error (below)
All emulators I have created allow for GPS but still the error persists. The code for onCreate where GPS is first required is below:
// Ensuring a location, loop till find it
do {
// Get the location manager
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Define the criteria how to select the location provider -> use
// default
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
// Just test displaying
lat = (float) (location.getLatitude());
lng = (float) (location.getLongitude());
} while (lat == 0.0);
The specific error message is:
java.lang.IllegalArgumentException: invalid provider: null at android.location.LocationManager.checkProvider(LocationManager.java:1623)