Geocoder gc = new Geocoder(this, Locale.CHINA);
result = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
这段代码执行,在模拟器下,可以根据locatiion的经纬度,获取地理信息,比如什么城市城街道但是代码放在真机上测试,然后的就是一个[],里面是空的,请问是怎么回事?需要额外的什么key吗?

解决方案 »

  1.   

    设备在室内一般是接收不到GPS卫星信号的,也就没法取得经纬度。你到室外去试试。
      

  2.   

      The returned values may be obtained by means of a network lookup. The results are a best guess and are not guaranteed to be meaningful or correct. It may be useful to call this method from a thread separate from your primary UI thread.
      建议不要在UI线程里调用该方法 
      

  3.   


    先定义一个Handler对象,然后在另外开一个线程执行:Geocoder gc = new Geocoder(this, Locale.CHINA);
    result = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);并在这个线程中,将得到的结果,通过sendMessage方法,触发Handler对象的handleMessage方法,在handleMessage方法中,更新显示。注意Handler对象,必须和界面元素在同一个线程里面。
      

  4.   

    楼上几位大侠的意思,我没有获取到数据就显示,导致为空,但是我在获取数据执行后,sleep了10秒钟,还是一样的效果啊。
      

  5.   

    1. 真机网络是否正常
    2. 真机是否支持google api,这个很重要,一般国内行货不支持可以使用下边的地址实现你的功能:
    http://ditu.google.com/maps/geo?q=39.998394075812634,116.39139175415039&output=xml&oe=utf8&hl=zh-CN&sensor=true&key=
      

  6.   


    您好,请问如何查自己的机器是否支持google的api啊