Geocoder suddenly stopped working

我的未来我决定 提交于 2019-12-13 08:11:47

问题


I am using Geocoder to get the lat and long in my android application. It was working fine some while back but now it just stopped working. I didn't change the code. Why this happned?

public void onItemClick(AdapterView adapterView, View view, int position, long id) {
        String str = (String) adapterView.getItemAtPosition(position);
    List<Address> addressList= null;
            if(str != null || str.equals("") ){
                Geocoder geocoder = new Geocoder(this);
                try {
                    addressList = geocoder.getFromLocationName(str, 1);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                Address address = addressList.get(0);
                //LatLng latLng = new LatLng(address.getLatitude(),address.getLongitude());
                Intent i = new Intent(Activity2.this, MainActivity.class);
                i.putExtra("location", str);
                i.putExtra("latitude", address.getLatitude());
                i.putExtra("longitude", address.getLongitude());
                startActivity(i);
            }
}

Thank you!!


回答1:


Are you receiving IOException: Timed out waiting for response from server error? Because I've already seen other posts where it is mentioned that Geocoder isn't functioning properly, even though it did earlier (a few hours/days ago). I went to the public ticket - https://code.google.com/p/gmaps-api-issues/issues/detail?id=9153 - that was made when this happened last January, and it seems there are others who are experiencing this. You did mention you didn't modify anything in the code, right?



来源:https://stackoverflow.com/questions/36390518/geocoder-suddenly-stopped-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!