use of android.telephony.TelephonyManager in project qksms by moezbhatti.
the class ApnUtils method getSimOperatorCodes.
public static String[] getSimOperatorCodes(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String simOperator = telephonyManager.getSimOperator();
String[] mccmnc = new String[] { null, null };
if (!TextUtils.isEmpty(simOperator)) {
mccmnc[0] = simOperator.substring(0, 3);
mccmnc[1] = simOperator.substring(3);
}
return mccmnc;
}
use of android.telephony.TelephonyManager in project Signal-Android by WhisperSystems.
the class TelephonyUtil method getMccMnc.
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;
}
}
use of android.telephony.TelephonyManager in project Klyph by jonathangerbaud.
the class Android method getDeviceUDID.
public static String getDeviceUDID(Context ctx) {
final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
PackageManager pm = ctx.getPackageManager();
int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
} else {
tmDevice = Settings.Secure.ANDROID_ID;
tmSerial = android.os.Build.SERIAL;
}
androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
use of android.telephony.TelephonyManager in project FastDev4Android by jiangqqlmj.
the class StrUtils method getIpBaseStation.
// 获取ip基站
public static String getIpBaseStation() {
TelephonyManager telMgr = (TelephonyManager) FDApplication.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
int cid = 0;
int lac = 0;
try {
if (telMgr != null) {
GsmCellLocation gc = (GsmCellLocation) telMgr.getCellLocation();
if (null == gc) {
return "0_0";
}
cid = gc.getCid();
lac = gc.getLac();
}
} catch (Exception e) {
if (telMgr != null) {
CdmaCellLocation location = (CdmaCellLocation) telMgr.getCellLocation();
if (null == location) {
return "0_0";
}
lac = location.getNetworkId();
cid = location.getBaseStationId();
cid /= 16;
}
}
return lac + "_" + cid;
}
use of android.telephony.TelephonyManager in project Klyph by jonathangerbaud.
the class Android method getDeviceUDID.
public static String getDeviceUDID(Context ctx) {
final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
PackageManager pm = ctx.getPackageManager();
int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
} else {
tmDevice = Settings.Secure.ANDROID_ID;
tmSerial = android.os.Build.SERIAL;
}
androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
Aggregations