-1
我正在使用地理編碼器來獲取lat和long在我的android應用程序。有些時候它工作得很好,但現在它停止工作。我沒有更改代碼。爲什麼這很受歡迎?Geocoder突然停止工作
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);
}
}
謝謝!
爲什麼有人會投票?至少告訴我們我們要去哪裏錯了? – user3304748
此通話需要Internet連接。當它不工作時你有互聯網連接嗎? –
雅我有互聯網連接。 7-8小時前它工作正常。 – user3304748