Geocoder works in 1.6 but not in 2.2 emulator

不羁岁月 提交于 2019-12-11 03:25:29

问题


getFromLocationName() alsways throws a NullPointerException in the Android 2.2 emulator but it's working fine in the Android 1.6 emulator.

This is my code snippet:

Geocoder geo = new Geocoder(GeocoderAppActivity.this, Locale.getDefault());     

try {       
    List<Address> add = geo.getFromLocationName("Tagore Road,Rajkot", 1);
    while (add.size() == 0) {
        Log.e("Girish", "in while");
        add = geo.getFromLocationName("Tagore Road,Rajkot", 1);
    }
}

What is wrong?


回答1:


In the emulator, are you using the regular Android 2.2, or the Google Apis [Android 2.2] version?

If you use the regular Android 2.2 one, it won't work. As far as I know it does not have the functionality to fulfill your actions. Open your SDK manager and download the Google Apis [Android 2.2] and create an AVD with that. Then try again, it should work.




回答2:


It's a known bug which they never fixed see service not available I think you will find that it works in the the API level 7 emulator.




回答3:


Yes this is a Bug but I think it shall run on device.



来源:https://stackoverflow.com/questions/8503693/geocoder-works-in-1-6-but-not-in-2-2-emulator

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