Skip to content

Instantly share code, notes, and snippets.

@jpzhu
Created September 25, 2013 08:47
Show Gist options
  • Save jpzhu/6696838 to your computer and use it in GitHub Desktop.
Save jpzhu/6696838 to your computer and use it in GitHub Desktop.
import java.util.List;
import android.location.Location;
import android.location.Geocoder;
import android.location.Address;
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
try{
List<Address> address_list = new Geocoder(mContext).getFromLocation(latitude,longitude,1);
if (address_list.size() > 0) {
Address address = address_list.get(0);
mCountry = address.getCountryName();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment