java.io.IOException异常:无法解析来自服务器在getFromLocationName() [英] java.io.IOException: Unable to parse response from server at getFromLocationName()
问题描述
我知道这个问题已经被问频繁过,但我无法得到任何回答或搜索结果的解决方案。 我要解决这个问题,尽快.. 我想获得的纬度和地址的经度由用户输入,但我继续获取:
I know the question has been asked frequently before ,but i am unable to get the solution from any answer or search results. I have to solve this issue ASAP .. I am trying to get the latitude and the longitude from the address enter by the user but i am continue getting :
java.io.IOException: Unable to parse response from server
我用这code:
I am using this code :
Geocoder geocoder = new Geocoder(this ,Locale.getDefault());
String newAddress = (String)saveas.getText().toString();
List<Address> addresses = geocoder.getFromLocationName(newAddress, 1);
我尝试了很多不同的可能方式,但没有什么工作? 默认的地图应用效果很好,当用户输入地址就说明成功地在map..How该地址可我做同样的..?
I tried a lot with different possible ways but nothing works... The default map application works well, when the user enter the address it shows sucessfully that address in the map..How can i do the same..?
我添加了所有所需的权限,我是真正的设备上测试它(版本2.3)
I have added all the required permissions and i am testing it on the real device(version 2.3)...
推荐答案
我解决了同样的问题不断变化的环境。
I solved the same issue changing the context.
我使用的片段,所以我的code是这样
I use Fragment, so my code is like this
public class SearchRoteFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.teste_mapa, container, false);
context = getActivity();
... }
... }
当我打电话地理code我这样做
and when I call geocode I do this
Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
这篇关于java.io.IOException异常:无法解析来自服务器在getFromLocationName()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!