public boolean onQueryTextSubmit(String query) {
String location = searchView.getQuery().toString();
List<Address> addressList = null;
if (location != null || !location.equals("")){
Geocoder geocoder = new Geocoder(Home.this);
try {
addressList = geocoder.getFromLocationName(location,1);
} catch (IOException e) {
e.printStackTrace();
}
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(),address.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));
}
Why I get NullPointerException
error from line Address address = addressList.get(0)
. I try to create searchbar in maps activity.