2010-11-11 145 views

回答

0

我不知道您是否可以訪問該信息。其中 位置數據,我知道你能存取權限正是這種

從上d.android.com Android開發者指南

「您可以使用上下文對象,Android可以提供查詢的語言環境:

String locale = context.getResources().getConfiguration().locale.getDisplayName(); 

編輯:哦,對你有什麼需要嗎?因爲如果您只想爲其製作不同的資源,您不需要訪問這些信息,因爲Android會爲您提供這些信息。請閱讀本地化章節中的d.android.com開發指南。

14
final TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 
if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { 
    final GsmCellLocation location = (GsmCellLocation) telephony.getCellLocation(); 
    if (location != null) { 
     msg.setText("LAC: " + location.getLac() + " CID: " + location.getCid()); 
    } 
} 

不要忘記設置ACCESS_COARSE_LOCATION或ACCESS_FINE_LOCATION,否則會得到SecurityExceptions。

例如添加以下到應用中體現你的<清單>元素:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
12

鍵入*#*#4636#*#*進入撥號器和可能是你在找什麼。

1

值是基地16 這樣使用它:

String cellId = Integer.toHexString(location.getCid()); 
String cellLac = Integer.toHexString(location.getLac());