• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Location problem

aminet73

Lurker
Hi,

I've published an application on the android market. I've been using the Location Service for retrieving the user's country code that is used for highscores etc.

The problem is that I only retrieve country codes from users which have the same nationality as me(Danish). In other words: I only get a small percentage of the users country code.

Any suggestions for what I'm missing? I'm using the default locale. Does the export wizard build in some language specific stuff?

Cheers
Anders
 
How are you accessing the locale information? Something like this?

String locale = context.getResources().getConfiguration().locale.getDisplayName();
 
Here is the snippet that I'm using for setting up the location manager and geocoder:

Code:
Geocoder geoCoder = new Geocoder(context.getBaseContext(), Locale
                .getDefault());
        
LocationManager locationManger = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);
And the code for retrieving the country code:

Code:
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setCostAllowed(false);
String provider = locationManager.getBestProvider(criteria,
             true);

List<String> providers = locationManager.getProviders(false);
String provider = null;
if (!providers.isEmpty()) {
         provider = providers.get(0);
}
if (provider != null) {
    Location location = locationManager             .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                if (location != null) {
                    List<Address> fromLocation = geoCoder.getFromLocation(
                            location.getLatitude(), location.getLongitude(), 3);

                    if (fromLocation != null) {
                        for (Address address : fromLocation) {
                            if (address.getCountryCode() != null) {
                                player.setCode(address.getCountryCode());
 
Back
Top Bottom