java.io.IOException: grpc failed

前端 未结 24 1039
野性不改
野性不改 2020-12-02 20:00

When I use call getFromLocationName I get an IOException with description \"grpc failed\".

Code that\'s ran

@Override
public void onMapReady(GoogleMa         


        
24条回答
  •  不思量自难忘°
    2020-12-02 20:33

    This worked for me.

    SomeTimes Geocoder failed when latitude and longitude contain above 3 decimal places, or it may be said that Geocoder can not decode every latitude and longitude. you need to limit latitude and longitude up to 3 decimal places.

    
        DecimalFormat df = new DecimalFormat();
    
        df.setMaximumFractionDigits(3);
    
        double lat = Double.parseDouble(df.format(currentUserLocation.latitude));
    
        double lon = Double.parseDouble(df.format(currentUserLocation.longitude));
    
        Geocoder geocoder = new Geocoder(myContext, Locale.getDefault());
    
        List
    addresses = geocoder.getFromLocation(lat,lon, 1); String cityName = addresses.get(0).getLocality();

    Source : https://github.com/xamarin/Essentials/issues/759#issuecomment-621270050

提交回复
热议问题