2016-01-25 37 views
0

我正在開發一個應用程序,它有一個過濾器,用戶可以通過其設備構建國家來分隔用戶。我正在使用:Se構建任何Android模擬器的國家

String locale = getResources().getConfiguration().locale.getCountry(); 

得到的國家。有沒有辦法在AVD上檢查構建國家,以便我可以確保上面的代碼正常工作?

回答

1

打開菜單=>設置=>語言&鍵盤=>選擇區域設置=>設置的任何區域,從這個

使用CMD:

$ adb shell' 
setprop persist.sys.language en; 
setprop persist.sys.country IN; 
stop; 
sleep 5; 
start' 

如果你想它programaically:

Locale locale = null; 
Configuration config=null; 
config = getBaseContext().getResources().getConfiguration(); 
locale = new Locale("en"); 
Locale.setDefault(locale); 
config.locale = locale;