DirectionsApiRequest 在 SDK 26 以下不工作 Android phone
DirectionsApiRequest not working below from SDK 26 Android phone
我正在使用 DirectionsApiRequest 从 google 获取方向信息它从 SDK 26 到更高版本都可以正常工作 android phone.But 它没有在 [=16= 上给出任何结果或错误] phone 下面到 SDK 26.
DirectionsApiRequest directionsApiRequest = new DirectionsApiRequest(mGeoApiContext);
directionsApiRequest.origin(new com.google.maps.model.LatLng(latLngList.get(0).latitude, latLngList.get(0).longitude));
directionsApiRequest.destination(new com.google.maps.model.LatLng(latLngList.get(1).latitude, latLngList.get(1).longitude));
directionsApiRequest.mode(TravelMode.DRIVING);
directionsApiRequest.alternatives(false);
directionsApiRequest.setCallback(new PendingResult.Callback<DirectionsResult>() {
@Override
public void onResult(DirectionsResult result) {
currentTripDuration = String.valueOf(result.routes[0].legs[0].duration);
currentTripTime = String.valueOf(result.routes[0].legs[0].distance);
}
@Override
public void onFailure(Throwable e) {
Log.e("calculateDirections", "calculateDirections: Failed to get directions: " + e.getMessage());
}
});
implementation 'com.google.android.gms:play-services-maps:17.0.0'
/*google location*/
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.libraries.places:places:2.4.0'
/*google direction*/
implementation 'com.google.maps:google-maps-services:0.15.0'
此 API 不推荐用于 Android 根据此问题的用法 https://github.com/googlemaps/google-maps-services-java/issues/552 请使用改造构建器
按方向 API
我正在使用 DirectionsApiRequest 从 google 获取方向信息它从 SDK 26 到更高版本都可以正常工作 android phone.But 它没有在 [=16= 上给出任何结果或错误] phone 下面到 SDK 26.
DirectionsApiRequest directionsApiRequest = new DirectionsApiRequest(mGeoApiContext);
directionsApiRequest.origin(new com.google.maps.model.LatLng(latLngList.get(0).latitude, latLngList.get(0).longitude));
directionsApiRequest.destination(new com.google.maps.model.LatLng(latLngList.get(1).latitude, latLngList.get(1).longitude));
directionsApiRequest.mode(TravelMode.DRIVING);
directionsApiRequest.alternatives(false);
directionsApiRequest.setCallback(new PendingResult.Callback<DirectionsResult>() {
@Override
public void onResult(DirectionsResult result) {
currentTripDuration = String.valueOf(result.routes[0].legs[0].duration);
currentTripTime = String.valueOf(result.routes[0].legs[0].distance);
}
@Override
public void onFailure(Throwable e) {
Log.e("calculateDirections", "calculateDirections: Failed to get directions: " + e.getMessage());
}
});
implementation 'com.google.android.gms:play-services-maps:17.0.0'
/*google location*/
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.libraries.places:places:2.4.0'
/*google direction*/
implementation 'com.google.maps:google-maps-services:0.15.0'
此 API 不推荐用于 Android 根据此问题的用法 https://github.com/googlemaps/google-maps-services-java/issues/552 请使用改造构建器
按方向 API