【发布时间】:2016-07-23 06:40:50
【问题描述】:
我正在使用 Geocoder 来获取我的 android 应用程序中的经纬度。前段时间它工作得很好,但现在它刚刚停止工作。我没有更改代码。为什么会这样?
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);
}
}
谢谢!!
【问题讨论】:
-
为什么有人反对投票?至少告诉我们哪里出了问题?
-
此呼叫需要互联网连接。当它不工作时你有互联网连接吗?
-
是的,我有互联网连接。它在 7-8 小时前运行良好。
-
服务可能不可用?看看这里:stackoverflow.com/questions/7109240/… 检查你的日志输出......
标签: android google-maps geocoding geocode