本文整理汇总了Java中android.telephony.TelephonyManager.getNetworkOperator方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getNetworkOperator方法的具体用法?Java TelephonyManager.getNetworkOperator怎么用?Java TelephonyManager.getNetworkOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.TelephonyManager
的用法示例。
在下文中一共展示了TelephonyManager.getNetworkOperator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPhoneStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机状态信息
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return DeviceId(IMEI) = 99000311726612<br>
* DeviceSoftwareVersion = 00<br>
* Line1Number =<br>
* NetworkCountryIso = cn<br>
* NetworkOperator = 46003<br>
* NetworkOperatorName = 中国电信<br>
* NetworkType = 6<br>
* honeType = 2<br>
* SimCountryIso = cn<br>
* SimOperator = 46003<br>
* SimOperatorName = 中国电信<br>
* SimSerialNumber = 89860315045710604022<br>
* SimState = 5<br>
* SubscriberId(IMSI) = 460030419724900<br>
* VoiceMailNumber = *86<br>
*/
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
TelephonyManager tm = (TelephonyManager) Utils.getApp()
.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "PhoneType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
示例2: getPhoneStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机状态信息
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return DeviceId(IMEI) = 99000311726612<br>
* DeviceSoftwareVersion = 00<br>
* Line1Number =<br>
* NetworkCountryIso = cn<br>
* NetworkOperator = 46003<br>
* NetworkOperatorName = 中国电信<br>
* NetworkType = 6<br>
* honeType = 2<br>
* SimCountryIso = cn<br>
* SimOperator = 46003<br>
* SimOperatorName = 中国电信<br>
* SimSerialNumber = 89860315045710604022<br>
* SimState = 5<br>
* SubscriberId(IMSI) = 460030419724900<br>
* VoiceMailNumber = *86<br>
*/
public static String getPhoneStatus() {
TelephonyManager tm = (TelephonyManager) Utils.getContext()
.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
示例3: getPhoneISP
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机网络运营商类型
*
* @param context
* @return
*/
public static String getPhoneISP(Context context) {
if (context == null) {
return "";
}
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String teleCompany = "";
String np = manager.getNetworkOperator();
if (np != null) {
if (np.equals(CMCC_ISP) || np.equals(CMCC2_ISP)) {
teleCompany = "中国移动";
} else if (np.startsWith(CU_ISP)) {
teleCompany = "中国联通";
} else if (np.startsWith(CT_ISP)) {
teleCompany = "中国电信";
}
}
return teleCompany;
}
示例4: getMccMnc
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getMccMnc(final Context context) {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final int configMcc = context.getResources().getConfiguration().mcc;
final int configMnc = context.getResources().getConfiguration().mnc;
if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
return tm.getSimOperator();
} else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
return tm.getNetworkOperator();
} else if (configMcc != 0 && configMnc != 0) {
Log.w(TAG, "Choosing MCC+MNC info from current context's Configuration");
return String.format("%03d%d",
configMcc,
configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
} else {
return null;
}
}
示例5: getPhoneStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机状态信息
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return DeviceId(IMEI) = 99000311726612<br>
* DeviceSoftwareVersion = 00<br>
* Line1Number =<br>
* NetworkCountryIso = cn<br>
* NetworkOperator = 46003<br>
* NetworkOperatorName = 中国电信<br>
* NetworkType = 6<br>
* honeType = 2<br>
* SimCountryIso = cn<br>
* SimOperator = 46003<br>
* SimOperatorName = 中国电信<br>
* SimSerialNumber = 89860315045710604022<br>
* SimState = 5<br>
* SubscriberId(IMSI) = 460030419724900<br>
* VoiceMailNumber = *86<br>
*/
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
TelephonyManager tm = (TelephonyManager) Utils.getContext()
.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "PhoneType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
示例6: getPhoneStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机状态信息
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return DeviceId(IMEI) = 99000311726612<br>
* DeviceSoftwareVersion = 00<br>
* Line1Number =<br>
* NetworkCountryIso = cn<br>
* NetworkOperator = 46003<br>
* NetworkOperatorName = 中国电信<br>
* NetworkType = 6<br>
* honeType = 2<br>
* SimCountryIso = cn<br>
* SimOperator = 46003<br>
* SimOperatorName = 中国电信<br>
* SimSerialNumber = 89860315045710604022<br>
* SimState = 5<br>
* SubscriberId(IMSI) = 460030419724900<br>
* VoiceMailNumber = *86<br>
*/
@SuppressLint("HardwareIds")
public static String getPhoneStatus(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "PhoneType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
示例7: b
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String b(Context context) {
String str = "";
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
if (telephonyManager == null) {
return str;
}
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator == null || networkOperator.length() < 3) {
networkOperator = str;
} else {
networkOperator = networkOperator.substring(0, 3);
}
return networkOperator;
} catch (Throwable th) {
th.printStackTrace();
return str;
}
}
示例8: getOperatorNameCode
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取网络运营商并且转换为有米原生广告请求协议中的网络运营商标识号
*
* @param context 上下文,会自动去ApplicationContext
*
* @return <ul>
* <li>空:无</li>
* <li>0: 未知/其他</li>
* <li>2: 中国移动</li>
* <li>3: 中国联通</li>
* <li>4: 中国电信</li>
* </ul>
*/
public static String getOperatorNameCode(Context context) {
try {
TelephonyManager telephonyManager =
(TelephonyManager) context.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
String operatorName = telephonyManager.getNetworkOperator();
if (!TextUtils.isEmpty(operatorName)) {
if (operatorName.equals("46000") || operatorName.equals("46002") || operatorName.equals("46007")) {
return "2";
}
if (operatorName.equals("46001") || operatorName.equals("46006")) {
return "3";
}
if (operatorName.equals("46003") || operatorName.equals("46005")) {
return "4";
}
return "0";
}
}
} catch (Throwable e) {
DLog.e(e);
}
return "";
}
示例9: getMCC
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private String getMCC() {
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
// 返回当前手机注册的网络运营商所在国家的MCC+MNC. 如果没注册到网络就为空.
String networkOperator = tm.getNetworkOperator();
if (!TextUtils.isEmpty(networkOperator)) {
return networkOperator;
}
// 返回SIM卡运营商所在国家的MCC+MNC. 5位或6位. 如果没有SIM卡返回空
return tm.getSimOperator();
}
示例10: getNetworkOperator
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getNetworkOperator(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return "";
}
return tm.getNetworkOperator();
}
示例11: getNetworkOperator
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* Returns the MCC+MNC (mobile country code + mobile network code) as
* the numeric name of the current registered operator.
*/
@CalledByNative
private static String getNetworkOperator(Context context) {
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager == null) return "";
return telephonyManager.getNetworkOperator();
}
示例12: getCountryCode
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@ReactMethod
public void getCountryCode(Promise promise){
String isoCountryCode="";
String mobileCountryCode="";
String mobileNetworkCode="";
int callPrefix;
TelephonyManager manager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);
isoCountryCode = manager.getSimCountryIso();
WritableMap map = Arguments.createMap();
map.putString("isoCountryCode", isoCountryCode);
mobileCountryCode = manager.getNetworkCountryIso();
map.putString("mobileCountryCode", mobileCountryCode);
mobileNetworkCode = manager.getNetworkOperator();
map.putString("mobileNetworkCode", mobileNetworkCode);
if(isoCountryCode.length() > 0){
int index = Arrays.asList(isoCodes).indexOf(isoCountryCode.toUpperCase());
callPrefix = prefixes[index];
map.putInt("callPrefix", callPrefix);
}else{
map.putString("callPrefix", null);
}
promise.resolve(map);
}
示例13: getNetworkOperator
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getNetworkOperator(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null) {
return tm.getNetworkOperator();
}
return null;
}
示例14: getNetworkOperator
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getNetworkOperator(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if(tm != null){
return tm.getNetworkOperator();
}
return null;
}
示例15: downloadBtsDataIfApiKeyAvailable
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private void downloadBtsDataIfApiKeyAvailable() {
if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) {
Cell cell = new Cell();
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tm.getNetworkOperator();
if (networkOperator != null && !networkOperator.isEmpty()) {
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
cell.setMCC(mcc);
int mnc = Integer.parseInt(networkOperator.substring(3));
cell.setMNC(mnc);
Log.d(TAG, mTAG + "CELL:: mcc=" + mcc + " mnc=" + mnc);
}
GeoLocation loc = mAimsicdService.lastKnownLocation();
if (loc != null) {
Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
cell.setLon(loc.getLongitudeInDegrees());
cell.setLat(loc.getLatitudeInDegrees());
Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST, mAimsicdService);
} else {
Helpers.msgShort(this, getString(R.string.waiting_for_location));
// This uses the LocationServices to get CID/LAC/MNC/MCC to be used
// for grabbing the BTS data from OCID, via their API.
// CID Location Async Output Delegate Interface Implementation
LocationServices.LocationAsync locationAsync
= new LocationServices.LocationAsync();
locationAsync.delegate = this;
locationAsync.execute(
mAimsicdService.getCell().getCID(),
mAimsicdService.getCell().getLAC(),
mAimsicdService.getCell().getMNC(),
mAimsicdService.getCell().getMCC());
}
} else {
Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected));
}
}