Get Phone region name programmatically

血红的双手。 提交于 2019-12-13 02:06:01

问题


I have to get phone no region (means from which region this no belongs) programmatically. I searched lot and didn't find anyway then I thought to get current location through network provider name but it return city name. Actually 1st I have to get phone no region if it not possible then through network provider how can we get region of current location. Please suggest me.


回答1:


Try Telephony Service.

TelephonyManager telman=(TelephonyManager) getSystemService(TELEPHONY_SERVICE);

a lot of info can retrieve as,

telman.getNetworkOperatorName();
telman.getSimSerialNumber();
telman.getLine1Number();
telman.getSubscriberId();

etc.

There is a method, telman.getCellLocation(); . I didn't try it yet, may be you can try.




回答2:


The easiest way to get the name of the Current Network Operator to which the Android phone is currently connected is to get hold of the android.telephony.TelephonyManager and get it from there:

TelephonyManager telephonyManager =((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();

similarly the sim operator can be retrieved by using:

String operatorName = telephonyManager.getSimOperatorName();


来源:https://stackoverflow.com/questions/17942150/get-phone-region-name-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!