Skip to content

Commit 73b1e61

Browse files
authored
Merge pull request #108 from svvashishtha/fix_npe
Fixed NPE in FusedLocationProvider.java
2 parents a5f06b5 + 2d10c69 commit 73b1e61

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

madlocationmanager/src/main/java/mad/location/manager/lib/Services/KalmanLocationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public KalmanLocationService() {
385385
@Override
386386
public void onCreate() {
387387
super.onCreate();
388-
fusedLocationProvider = new FusedLocationProvider(this);
388+
fusedLocationProvider = new FusedLocationProvider(this,this);
389389
gpsLocationProvider = new GPSLocationProvider(this, this, this);
390390
m_sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
391391
m_powerManager = (PowerManager) getSystemService(POWER_SERVICE);

madlocationmanager/src/main/java/mad/location/manager/lib/locationProviders/FusedLocationProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public void onLocationResult(LocationResult locationResult) {
4545

4646
@Override
4747
public void onLocationAvailability(LocationAvailability locationAvailability) {
48+
builder =new LocationSettingsRequest.Builder()
49+
.addLocationRequest(m_locationRequest);
50+
client = LocationServices.getSettingsClient(context);
4851
task = client.checkLocationSettings(builder.build());
4952
task.addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
5053
@Override
@@ -62,9 +65,10 @@ public void onFailure(@NonNull Exception e) {
6265
}
6366
};
6467

65-
public FusedLocationProvider(Context context) {
68+
public FusedLocationProvider(Context context,LocationProviderCallback m_locationProvider ) {
6669
this.m_fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
6770
this.context = context;
71+
this.m_locationProvider = m_locationProvider;
6872
}
6973

7074
@RequiresPermission(
@@ -88,9 +92,5 @@ public void stop() {
8892
public boolean isProviderEnabled() {
8993
return LocationManagerCompat.isLocationEnabled((LocationManager) context.getSystemService(Context.LOCATION_SERVICE));
9094
}
91-
public interface CheckLocationSettingCallback{
92-
void onSuccess(LocationSettingsResponse locationSettingsResponse);
93-
void onFailure(@NonNull Exception e);
94-
}
9595
}
9696

0 commit comments

Comments
 (0)