Geocoder无法在真实设备中使用

时间:2015-03-30 04:55:45

标签: android gps geocode

private void test(){
        Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
        String ret = "";
        try {
            List<Address> addresses = geocoder.getFromLocation(-6.267563,
                    106.934707, 1);
            if (addresses != null) {
                Address returnedAddress = addresses.get(0);
                StringBuilder strReturnedAddress = new StringBuilder(
                        "Address:\n");
                for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
                    strReturnedAddress
                            .append(returnedAddress.getAddressLine(i)).append(
                                    "\n");
                }
                ret = strReturnedAddress.toString();
            } else {
                ret = "No Address returned!";
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            ret = "Can't get Address!";
        }
        Toast.makeText(this, ret, Toast.LENGTH_LONG).show();
    }

我尝试运行此代码,并在我的模拟器中工作 (设置)&gt;&gt; http://prntscr.com/6n4tk7 我安装在我的设备中,它得到输出&#34;无法获得地址&#34;。我的手机是果冻豆,GPS和互联网都打开了。 问题是什么?抱歉我的英语不好。

更新:

我尝试在其他模拟器上运行,并且仅在模拟器目标Google API中运行。

  
    
      

http://prntscr.com/6n4tk7

    
  

0 个答案:

没有答案