Skip to content
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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Rkareko
Copy link
Contributor

@Rkareko Rkareko commented Sep 1, 2020

Add a null check for locationManager when getLastLocation is called.
Initialize locationManager if it is null

@coveralls
Copy link

coveralls commented Sep 1, 2020

@@ -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);
Copy link
Contributor

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

@Rkareko Rkareko marked this pull request as draft September 3, 2020 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants