use*_*286 1 android country-codes
我可以找到countryISO
TelephonyManager tManager =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryis = tManager.getSimCountryIso();
Run Code Online (Sandbox Code Playgroud)
和我使用的电话号码
String tnumber = tManager.getLine1Number();
Run Code Online (Sandbox Code Playgroud)
但我希望countryISO代码的国家/地区代码如+91或+92(取决于国家/地区).
如果我使用libphonenumber.jar它会直截了当吗?或者电话管理员还有其他代码吗?
And*_* me 11
经过4个小时的数据录入后,我根据我的要求制作了一个countryCodes实际数组文件,希望这对你也有帮助....
只需复制代码下面的粘贴,并将data.java文件放入您的包中,您可以在项目的任何位置调用该数组我还提到了如何在adpater中调用它.微调
下面的数组代码,名称,areacode都在索引的相同序列中我已经验证了它,数组中的数据来自维基百科
这是你的解决方案
data.java
package your_package_name;
public class data {
public static final String[] countryNames = { "Afghanistan", "Albania",
"Algeria", "Andorra", "Angola", "Antarctica", "Argentina",
"Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
"Bahrain", "Bangladesh", "Belarus", "Belgium", "Belize", "Benin",
"Bhutan", "Bolivia", "Bosnia And Herzegovina", "Botswana",
"Brazil", "Brunei Darussalam", "Bulgaria", "Burkina Faso",
"Myanmar", "Burundi", "Cambodia", "Cameroon", "Canada",
"Cape Verde", "Central African Republic", "Chad", "Chile", "China",
"Christmas Island", "Cocos (keeling) Islands", "Colombia",
"Comoros", "Congo", "Cook Islands", "Costa Rica", "Croatia",
"Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti",
"Timor-leste", "Ecuador", "Egypt", "El Salvador",
"Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia",
"Falkland Islands (malvinas)", "Faroe Islands", "Fiji", "Finland",
"France", "French Polynesia", "Gabon", "Gambia", "Georgia",
"Germany", "Ghana", "Gibraltar", "Greece", "Greenland",
"Guatemala", "Guinea", "Guinea-bissau", "Guyana", "Haiti",
"Honduras", "Hong Kong", "Hungary", "India", "Indonesia", "Iran",
"Iraq", "Ireland", "Isle Of Man", "Israel", "Italy", "Ivory Coast",
"Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati",
"Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho",
"Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
"Macao", "Macedonia", "Madagascar", "Malawi", "Malaysia",
"Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania",
"Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
"Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique",
"Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia",
"New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Korea",
"Norway", "Oman", "Pakistan", "Palau", "Panama",
"Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn",
"Poland", "Portugal", "Puerto Rico", "Qatar", "Romania",
"Russian Federation", "Rwanda", "Saint Barthélemy", "Samoa",
"San Marino", "Sao Tome And Principe", "Saudi Arabia", "Senegal",
"Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia",
"Slovenia", "Solomon Islands", "Somalia", "South Africa",
"Korea, Republic Of", "Spain", "Sri Lanka", "Saint Helena",
"Saint Pierre And Miquelon", "Sudan", "Suriname", "Swaziland",
"Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan",
"Tajikistan", "Tanzania", "Thailand", "Togo", "Tokelau", "Tonga",
"Tunisia", "Turkey", "Turkmenistan", "Tuvalu",
"United Arab Emirates", "Uganda", "United Kingdom", "Ukraine",
"Uruguay", "United States", "Uzbekistan", "Vanuatu",
"Holy See (vatican City State)", "Venezuela", "Viet Nam",
"Wallis And Futuna", "Yemen", "Zambia", "Zimbabwe" };
public static final String[] countryAreaCodes = { "93", "355", "213",
"376", "244", "672", "54", "374", "297", "61", "43", "994", "973",
"880", "375", "32", "501", "229", "975", "591", "387", "267", "55",
"673", "359", "226", "95", "257", "855", "237", "1", "238", "236",
"235", "56", "86", "61", "61", "57", "269", "242", "682", "506",
"385", "53", "357", "420", "45", "253", "670", "593", "20", "503",
"240", "291", "372", "251", "500", "298", "679", "358", "33",
"689", "241", "220", "995", "49", "233", "350", "30", "299", "502",
"224", "245", "592", "509", "504", "852", "36", "91", "62", "98",
"964", "353", "44", "972", "39", "225", "1876", "81", "962", "7",
"254", "686", "965", "996", "856", "371", "961", "266", "231",
"218", "423", "370", "352", "853", "389", "261", "265", "60",
"960", "223", "356", "692", "222", "230", "262", "52", "691",
"373", "377", "976", "382", "212", "258", "264", "674", "977",
"31", "687", "64", "505", "227", "234", "683", "850", "47", "968",
"92", "680", "507", "675", "595", "51", "63", "870", "48", "351",
"1", "974", "40", "7", "250", "590", "685", "378", "239", "966",
"221", "381", "248", "232", "65", "421", "386", "677", "252", "27",
"82", "34", "94", "290", "508", "249", "597", "268", "46", "41",
"963", "886", "992", "255", "66", "228", "690", "676", "216", "90",
"993", "688", "971", "256", "44", "380", "598", "1", "998", "678",
"39", "58", "84", "681", "967", "260", "263" };
public static final String[] countryCodes = { "AF", "AL", "DZ", "AD", "AO",
"AQ", "AR", "AM", "AW", "AU", "AT", "AZ", "BH", "BD", "BY", "BE",
"BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "BN", "BG", "BF", "MM",
"BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CX", "CC",
"CO", "KM", "CG", "CK", "CR", "HR", "CU", "CY", "CZ", "DK", "DJ",
"TL", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ",
"FI", "FR", "PF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL",
"GT", "GN", "GW", "GY", "HT", "HN", "HK", "HU", "IN", "ID", "IR",
"IQ", "IE", "IM", "IL", "IT", "CI", "JM", "JP", "JO", "KZ", "KE",
"KI", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT",
"LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MR",
"MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MA", "MZ", "NA",
"NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "KP", "NO",
"OM", "PK", "PW", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT",
"PR", "QA", "RO", "RU", "RW", "BL", "WS", "SM", "ST", "SA", "SN",
"RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES",
"LK", "SH", "PM", "SD", "SR", "SZ", "SE", "CH", "SY", "TW", "TJ",
"TZ", "TH", "TG", "TK", "TO", "TN", "TR", "TM", "TV", "AE", "UG",
"GB", "UA", "UY", "US", "UZ", "VU", "VA", "VE", "VN", "WF", "YE",
"ZM", "ZW",
};
}
Run Code Online (Sandbox Code Playgroud)
从data.java文件设置上面的数组使用下面的代码下面的代码只是样本snippest供您理解
对于countryName
ArrayAdapter<String> countryName = new ArrayAdapter<String>(_con,
android.R.layout.simple_spinner_item, data.countryNames);
Run Code Online (Sandbox Code Playgroud)
对于countryCodes
ArrayAdapter<String> countryName = new ArrayAdapter<String>(_con,
android.R.layout.simple_spinner_item, data.countryCodes);
Run Code Online (Sandbox Code Playgroud)
for countryAreaCodes
ArrayAdapter<String> countryName = new ArrayAdapter<String>(_con,
android.R.layout.simple_spinner_item, data.countryAreaCodes);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4034 次 |
| 最近记录: |