Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 1.12 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. get the iso3 country code
  2. geocoder = new Geocoder(this);
  3.      locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
  4.     Criteria criteria = new Criteria();
  5.     bestProvider =locationManager.getBestProvider(criteria,false);
  6.     location = locationManager.getLastKnownLocation(bestProvider);
  7.     if(location!=null)
  8.     {
  9.       lat=location.getLatitude();
  10.       lng=location.getLongitude();
  11.     }
  12.     else
  13.      {
  14.     location = new Location("");
  15.     location.setLatitude((double)38.0000000000);
  16.     location.setLongitude((double)-97.0000000000);
  17.     lat =location.getLatitude();
  18.     lng=location.getLongitude();
  19.      }
  20.     Log.e("","Latitude and Longitude"+"Latitude="+lat+"Longitude="+lng);
  21.     try
  22.     {  
  23.     addresses=geocoder.getFromLocation(lat,lng, 1);
  24.     }
  25.     catch (IOException e)
  26.     {  
  27.       e.printStackTrace();
  28.     }
  29.     if (addresses != null && addresses.size() > 0)
  30.     {
  31.      Address address = addresses.get(0);
  32.      Log.e("Address=",""+address);
  33.      locale = address.getCountryCode();
  34.      Log.e("Locale",""+locale);
  35.      Toast.makeText(SongsList.this,  "LocaleName"+locale,Toast.LENGTH_LONG).show();
  36.     }