0% found this document useful (0 votes)
7 views1 page

Android Geocoding and Reverse Geocoding

The document discusses geocoding in Android, including forward geocoding to convert an address string to latitude and longitude, reverse geocoding to convert latitude and longitude to an address string, and requiring the INTERNET and ACCESS_NETWORK_STATE permissions in the app manifest.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Android Geocoding and Reverse Geocoding

The document discusses geocoding in Android, including forward geocoding to convert an address string to latitude and longitude, reverse geocoding to convert latitude and longitude to an address string, and requiring the INTERNET and ACCESS_NETWORK_STATE permissions in the app manifest.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Geocoding

import [Link];
import [Link];

// Address string
String addressString = "1600 Amphitheatre Parkway, Mountain View, CA";

try {
Geocoder geocoder = new Geocoder(context);
List<Address> addresses = [Link](addressString, 1);
if (addresses != null && ![Link]()) {
Address address = [Link](0);
double latitude = [Link]();
double longitude = [Link]();
// Use latitude and longitude
} else {
// Address not found
}
} catch (IOException e) {
[Link]();
}

Reverse Geocoding

import [Link];
import [Link];

// Latitude and Longitude


double latitude = 37.4233438;
double longitude = -122.0728817;

try {
Geocoder geocoder = new Geocoder(context);
List<Address> addresses = [Link](latitude, longitude, 1);
if (addresses != null && ![Link]()) {
Address address = [Link](0);
String addressString = [Link](0);
// Use addressString
} else {
// Address not found
}
} catch (IOException e) {
[Link]();
}

Manifest XML

<uses-permission android:name="[Link]" />


<uses-permission android:name="[Link].ACCESS_NETWORK_STATE" />

You might also like