From d3c35f5b4911bbf159f002a66ab8e42ecd0930a6 Mon Sep 17 00:00:00 2001 From: "alexander.zhuk" Date: Thu, 29 Dec 2016 15:07:42 +0300 Subject: [PATCH] fix no provider found exception --- .../location/providers/LocationManagerProvider.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java index 75567a5a..194b4025 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java @@ -62,8 +62,17 @@ public void start(OnLocationUpdatedListener listener, LocationParams params, boo } locationManager.requestSingleUpdate(criteria, this, Looper.getMainLooper()); } else { + String provider = locationManager.getBestProvider(criteria, true); + if (provider == null) { + logger.e("No provider found for criteria %s", criteria.toString()); + return; + } locationManager.requestLocationUpdates( - params.getInterval(), params.getDistance(), criteria, this, Looper.getMainLooper()); + provider, + params.getInterval(), + params.getDistance(), + this, Looper.getMainLooper() + ); } }