getNetworkCountryIso()仅在Galaxy s5上返回空

时间:2015-04-27 07:33:34

标签: java android

使用Given代码,我可以获得galaxy s4的国家代码,但我无法获得galaxy 25上的国家/地区代码

public String GetCountryZipCode() {
    String CountryID = "";
    String CountryZipCode = "";

    TelephonyManager manager = (TelephonyManager) LoginActivity.this
                .getSystemService(Context.TELEPHONY_SERVICE);
    // getNetworkCountryIso
    CountryID = manager.getNetworkCountryIso().toUpperCase();
    String[] rl = this.getResources().getStringArray(
        R.array.CountryCodesNew);
    for (int i = 0; i < rl.length; i++) {
        String[] g = rl[i].split(",");
        if (g[1].trim().equals(CountryID.trim())) {
            CountryZipCode = g[0];
            break;
        }
    }

    return CountryZipCode;
}

0 个答案:

没有答案