Issue in getting the complete address from lat and long in android device
I am using the below code and getting the null value in addresses .Code is
as follows:-
Geocoder geocoder;
List<Address> addresses;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
geocoder = new Geocoder(this, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(28.5202154,77.2006815, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(1);
String country = addresses.get(0).getAddressLine(2);
Toast.makeText(
MainActivity.this,""+address+" "+city+" "+country,
Toast.LENGTH_LONG).show();
}
when I debug the code, it gives an exception which is caught in catch
block is Service not available and when i run the same code in other
device it excutes normally and gives the complete address as required.
Guys please try to solve this issue.Thanks in advance!!
No comments:
Post a Comment