Skip to content

Commit

Permalink
Merge pull request #108 from svvashishtha/fix_npe
Browse files Browse the repository at this point in the history
Fixed NPE in FusedLocationProvider.java
  • Loading branch information
Lezh1k authored Feb 25, 2021
2 parents a5f06b5 + 2d10c69 commit 73b1e61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public KalmanLocationService() {
@Override
public void onCreate() {
super.onCreate();
fusedLocationProvider = new FusedLocationProvider(this);
fusedLocationProvider = new FusedLocationProvider(this,this);
gpsLocationProvider = new GPSLocationProvider(this, this, this);
m_sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
m_powerManager = (PowerManager) getSystemService(POWER_SERVICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public void onLocationResult(LocationResult locationResult) {

@Override
public void onLocationAvailability(LocationAvailability locationAvailability) {
builder =new LocationSettingsRequest.Builder()
.addLocationRequest(m_locationRequest);
client = LocationServices.getSettingsClient(context);
task = client.checkLocationSettings(builder.build());
task.addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
@Override
Expand All @@ -62,9 +65,10 @@ public void onFailure(@NonNull Exception e) {
}
};

public FusedLocationProvider(Context context) {
public FusedLocationProvider(Context context,LocationProviderCallback m_locationProvider ) {
this.m_fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
this.context = context;
this.m_locationProvider = m_locationProvider;
}

@RequiresPermission(
Expand All @@ -88,9 +92,5 @@ public void stop() {
public boolean isProviderEnabled() {
return LocationManagerCompat.isLocationEnabled((LocationManager) context.getSystemService(Context.LOCATION_SERVICE));
}
public interface CheckLocationSettingCallback{
void onSuccess(LocationSettingsResponse locationSettingsResponse);
void onFailure(@NonNull Exception e);
}
}

0 comments on commit 73b1e61

Please sign in to comment.