當我按國家名搜索時,它工作得很完美,但是當我搜索城市或地點時,應用程序崩潰。下面是代碼:當我搜索城市(或任何其他國家名稱)時,Android中的地理位置投擲異常
EditText location_tf = (EditText)findViewById(R.id.TFaddress);
String location = location_tf.getText().toString();
//Toast.makeText(this, location, Toast.LENGTH_SHORT).show();
Geocoder gc = new Geocoder(this);
List<Address> list = gc.getFromLocationName(location, 1);
Address add = list.get(0);
String locality = add.getLocality();
Toast.makeText(this, locality, Toast.LENGTH_SHORT).show();
double lat = add.getLatitude();
double lng = add.getLongitude();
gotoLocation(lat, lng, 4);
發佈您的問題的異常跟蹤 –