2012-03-02 3 views
-2

iso3 국가 코드를 얻는 방법. 내가 서버를 저장하지만 데이터베이스를 100 % 저장하지 않습니까? 나는 ...이 code.Please 나에게 감사와 사전에 도움 사용하고iso 국가 코드 받기

geocoder = new Geocoder(this); 
locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); 
Criteria criteria = new Criteria(); 
bestProvider =locationManager.getBestProvider(criteria,false); 
location = locationManager.getLastKnownLocation(bestProvider); 
if(location!=null) 
{ 
    lat=location.getLatitude(); 
    lng=location.getLongitude(); 
} 
else 
{ 
location = new Location(""); 
location.setLatitude((double)38.0000000000); 
location.setLongitude((double)-97.0000000000); 
lat =location.getLatitude(); 
lng=location.getLongitude(); 
} 
Log.e("","Latitude and Longitude"+"Latitude="+lat+"Longitude="+lng); 
try 
{ 
addresses=geocoder.getFromLocation(lat,lng, 1); 
} 
catch (IOException e) 
{ 
    e.printStackTrace(); 
} 
if (addresses != null && addresses.size() > 0) 
{ 
Address address = addresses.get(0); 
Log.e("Address=",""+address); 
locale = address.getCountryCode(); 
Log.e("Locale",""+locale); 
Toast.makeText(SongsList.this, "LocaleName"+locale,Toast.LENGTH_LONG).show(); 
} 

답변

1

countryISO3 = context.getResources(). getConfiguration를(). locale.getISO3Country()?

+0

, 나는 두 개의 모바일 삼성 갤럭시 에이스를 가지고 htc의 Desire.HTC 욕망이 (IND) 제대로 작동과 삼성 갤럭시 에이스 국가 코드 영국 (GRB)을 얻습니다. –

+0

대답이 있습니까? –

+0

제발 고마워요 도와주세요 .. –

0

국가에서 ISO 코드를 얻으려면 : 이미이 code.Actually을 사용하고

TelephonyManager tm; 
tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE); 
String loc = tm.getSimCountryIso(); 
Toast.makeText(SongsList.this, "LocaleName" + loc, Toast.LENGTH_LONG).show(); 
+0

로밍의 경우 SIM 카드의 국가가 사용자에게 실제로있는 국가와 다를 수 있음을 지적해야합니다. 또한 장치에 SIM이 없을 수도 있습니다. – njzk2

관련 문제