Created
September 25, 2013 08:47
-
-
Save jpzhu/6696838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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