I am using Geocoder to get the lat and long in my android application. It was working fine some while back but now it just stopped working. I didn't change the code. Why this happned?
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);
}
}
Thank you!!