-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize location manager if null when getting last location #348
base: master
Are you sure you want to change the base?
Conversation
@@ -128,6 +128,9 @@ public void onResult(@NonNull LocationSettingsResult locationSettingsResult) { | |||
@Nullable | |||
@Override | |||
public Location getLastLocation() { | |||
if (locationManager == null) { | |||
locationManager = (LocationManager) context.getApplicationContext().getSystemService(Context.LOCATION_SERVICE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to investigate why location manager is getting null. With this fix we don't know which other methods maybe broken because of this.
Either create a method locationManager()
that if the references location manager is null reinitializes it so that it can be used in other methods until its known why location manager is becoming null
Add a null check for
locationManager
whengetLastLocation
is called.Initialize
locationManager
if it is null