3636import com .google .android .gms .common .api .GoogleApiClient .OnConnectionFailedListener ;
3737import com .google .android .gms .location .Geofence ;
3838import com .google .android .gms .location .Geofence .Builder ;
39+ import com .google .android .gms .location .GeofencingRequest ;
3940import com .google .android .gms .location .LocationListener ;
4041import com .google .android .gms .location .LocationRequest ;
4142import com .google .android .gms .location .LocationServices ;
@@ -264,6 +265,9 @@ private boolean isMetaDataSet() {
264265 }
265266 }
266267
268+ // Suppressing missing permission warning which since it is up to client to add location
269+ // permission to their manifest.
270+ @ SuppressWarnings ("MissingPermission" )
267271 private void updateTrackedGeofences () {
268272 if (allGeofences == null || googleApiClient == null || !googleApiClient .isConnected ()) {
269273 return ;
@@ -282,8 +286,11 @@ private void updateTrackedGeofences() {
282286 }
283287 trackedGeofenceIds = new ArrayList <>();
284288 if (toBeTrackedGeofences != null && toBeTrackedGeofences .size () > 0 ) {
285- LocationServices .GeofencingApi .addGeofences (
286- googleApiClient , toBeTrackedGeofences , getTransitionPendingIntent ());
289+ GeofencingRequest request = new GeofencingRequest .Builder ()
290+ .addGeofences (toBeTrackedGeofences )
291+ .build ();
292+ LocationServices .GeofencingApi .addGeofences (googleApiClient ,
293+ request , getTransitionPendingIntent ());
287294 for (Geofence geofence : toBeTrackedGeofences ) {
288295 trackedGeofenceIds .add (geofence .getRequestId ());
289296 //TODO: stateBeforeBackground doesn't get persisted.
@@ -432,6 +439,9 @@ public void onLocationChanged(Location location) {
432439 /**
433440 * Request location for user location update if googleApiClient is connected.
434441 */
442+ // Suppressing missing permission warning which since it is up to client to add location
443+ // permission to their manifest.
444+ @ SuppressWarnings ("MissingPermission" )
435445 private void requestLocation () {
436446 if (!Leanplum .isLocationCollectionEnabled () || googleApiClient == null
437447 || !googleApiClient .isConnected ()) {
0 commit comments