私はGoogleマップのアクティビティを使用しています。しかし、それは実際の場所と完全に動作します。どうやってクラッシュするのを防ぐことができますか?は、入力した場所が実際でないときにシャットダウンします。
マイコード:
public void onSearch(View view) {
String location = locationTS.getText().toString();
if (location != null || !location.equals("")) {
Geocoder geocoder = new Geocoder(this);
List<Address> addressList=null;
try {
addressList= geocoder.getFromLocationName(location, 1);
mMap.clear();
} catch (IOException e) {
e.printStackTrace();
}
Address address=addressList.get(0);
LatLng latLng=new LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("Marker"));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,80));
latitudeB=latLng.latitude;
longitudeB=latLng.longitude;
}
else {
Toast.makeText(getApplicationContext(), "please fill in an available location",
Toast.LENGTH_LONG).show();
}
}
はまだクラッシュ.. –
をここでログの猫を投稿してください –