-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Description
When using an Android device that does not have Google Play Services installed, LocationEngineProvider obtains the wrong LocationEngine. If the application includes dependencies for com.google.android.gms.location.LocationServices, a false positive returns LocationEngine.Type.GOOGLE_PLAY_SERVICES.
Steps to reproduce
- Use a device that does not have Google Play Services (or the play store) installed. Example: DJI Crystal Sky
- Use the latest MapBox SDK's
LocationEngineProvidertoobtainBestLocationEngineAvailable() - Observe the
LocationEngineprovided isLocationEngine.Type.GOOGLE_PLAY_SERVICESwhich can not be used if the device does not have Google Play Services installed
Expected behavior
The LocationEngineProvider should provide LocationEngine with LocationEngine.Type.ANDROID
Actual behavior
The LocationEngine provides LocationEngine.Type.GOOGLE_PLAY_SERVICES
Configuration
DJI Crystal Sky running (Android API level 22), no Play Services
mapbox-android-sdk:6.6.1
mapbox-android-plugin-locationlayer:0.11.0
My Workaround
private LocationEngine obtainBestLocationEngineAvailable(Context context) {
if (PlayServicesUtils.checkPlayServices(context)) {
return new LocationEngineProvider(context).obtainBestLocationEngineAvailable();
} else {
return new LocationEngineProvider(context)
.obtainLocationEngineBy(LocationEngine.Type.ANDROID);
}
}/**
* Check the device to make sure it has the Google Play Services APK. If
* it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*/
public static boolean checkPlayServices(Context context) {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
return resultCode == ConnectionResult.SUCCESS;
}This will ensure that the device has Google Play Services, which is required for LocationEngine.Type.GOOGLE_PLAY_SERVICES aka Google's FusedLocationProvider
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels