地理编码器突然停止工作 [英] Geocoder suddenly stopped working

查看:106
本文介绍了地理编码器突然停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Geocoder来获取lat和long在我的android应用程序中。有些时候它工作得很好,但现在它停止工作。我没有更改代码。为什么这很容易?

  public void onItemClick(AdapterView adapterView,View view,int position,long id){
String str =(String)adapterView.getItemAtPosition(position);
列表<地址> addressList = null;
if(str!= null || str.equals()){
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(str,1);
} catch(IOException e){
e.printStackTrace();
}
地址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);


$ / code>

谢谢!!

解决方案

您是否收到 IOException:超时等待服务器响应错误?因为我已经看到其他提到的 Geocoder 功能不正常的帖子,尽管它早些时候(几小时/几天前)确实运行正常。我去了公共门票 - https://代码。 google.com/p/gmaps-api-issues/issues/detail?id=9153 - 当去年1月份发生这种情况时发生了这种情况,似乎也有其他人遇到这种情况。你确实提到过你没有修改代码中的任何内容,对吧?

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!!

解决方案

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?

这篇关于地理编码器突然停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆