本文整理了Java中android.telephony.TelephonyManager.getSimSerialNumber()
方法的一些代码示例,展示了TelephonyManager.getSimSerialNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getSimSerialNumber()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getSimSerialNumber
暂无
代码示例来源:origin: stackoverflow.com
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
String getSimNumber = telemamanger.getLine1Number();
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasSimSerialNumber(String serialNumber) {
isNotNull();
String actualSerialNumber = actual.getSimSerialNumber();
assertThat(actualSerialNumber) //
.overridingErrorMessage("Expected SIM serial number <%s> but was <%s>.", serialNumber,
actualSerialNumber) //
.isEqualTo(serialNumber);
return this;
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = SecurityException.class)
public void getSimSerialNumber_shouldThrowSecurityExceptionWhenReadPhoneStatePermissionNotGranted()
throws Exception {
shadowOf(telephonyManager).setReadPhoneStatePermission(false);
telephonyManager.getSimSerialNumber();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGetSimSerialNumber() {
shadowOf(telephonyManager).setSimSerialNumber("SomeSerialNumber");
assertEquals("SomeSerialNumber", telephonyManager.getSimSerialNumber());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager telemamanger = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
代码示例来源:origin: oasisfeng/condom
@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() throws NameNotFoundException {
final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
new CondomOptions().addKit(new NullDeviceIdKit()));
final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
assertNotNull(tm);
assertTrue(tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
final TelephonyManager app_tm = (TelephonyManager) condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
assertNotNull(app_tm);
assertTrue(app_tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
assertPermission(condom, READ_PHONE_STATE, true);
assertNull(tm.getDeviceId());
if (SDK_INT >= LOLLIPOP) {
if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
assertNull(tm.getImei());
assertNull(tm.getImei(0));
if (SDK_INT >= O) assertNull(tm.getMeid());
if (SDK_INT >= O) assertNull(tm.getMeid(0));
}
assertNull(tm.getSimSerialNumber());
assertNull(tm.getLine1Number());
assertNull(tm.getSubscriberId());
}
代码示例来源:origin: Blizzard-liu/AndroidUtils
/**
* 获取设备唯一标识
* @param context
* @return
*/
public static String getUUID(Context context) {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
if (BuildConfig.DEBUG) Log.d(TAG, "uuid=" + uniqueId);
return uniqueId;
}
代码示例来源:origin: jingle1267/android-utils
/**
* 获取设备唯一标识 本方法调用需要READ_PHONE_STATE权限
*
* @param context
* @return
*/
public static String getUUID(Context context) {
String tmDevice = "", tmSerial = "", tmPhone = "", androidId = "";
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE)
== PackageManager.PERMISSION_GRANTED) {
try {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
} catch (Exception e) {
Log.e("AppUtils", "exception:" + e.getMessage());
}
} else {
Log.e("AppUtils", "没有 android.permission.READ_PHONE_STATE 权限");
tmDevice = "device";
tmSerial = "serial";
androidId = "androidid";
}
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
if (BuildConfig.DEBUG) Log.d(TAG, "uuid=" + uniqueId);
return uniqueId;
}
代码示例来源:origin: jingle1267/android-utils
String sn = tm.getSimSerialNumber();
if(!TextUtils.isEmpty(sn)){
deviceId.append("sn");
代码示例来源:origin: ac-pm/Inspeckage
li.add(new FingerprintItem("TelephonyManager", "IMSI", mTelephonyManager.getSubscriberId(), mTelephonyManager.getSubscriberId(), false));
li.add(new FingerprintItem("TelephonyManager", "PhoneNumber", mTelephonyManager.getLine1Number(), mTelephonyManager.getLine1Number(), false));
li.add(new FingerprintItem("TelephonyManager", "SimSerial", mTelephonyManager.getSimSerialNumber(), mTelephonyManager.getSimSerialNumber(), false));
li.add(new FingerprintItem("TelephonyManager", "CarrierCode", mTelephonyManager.getNetworkOperator(), mTelephonyManager.getNetworkOperator(), false));
li.add(new FingerprintItem("TelephonyManager", "Carrier", mTelephonyManager.getNetworkOperatorName(), mTelephonyManager.getNetworkOperatorName(), false));
li.add(new FingerprintItem("TelephonyManager", "SimCountry", mTelephonyManager.getSimCountryIso(), mTelephonyManager.getSimCountryIso(), false));
li.add(new FingerprintItem("TelephonyManager", "NetworkCountry", mTelephonyManager.getNetworkCountryIso(), mTelephonyManager.getNetworkCountryIso(), false));
li.add(new FingerprintItem("TelephonyManager", "SimSerialNumber", mTelephonyManager.getSimSerialNumber(), mTelephonyManager.getSimSerialNumber(), false));
代码示例来源:origin: stackoverflow.com
public String getSimSerialNumber(){
TelephonyManager tm = (TelephonyManager)this.getActivity().getSystemService(this.getActivity().TELEPHONY_SERVICE);
String number = tm.getSimSerialNumber();
return number;
}
代码示例来源:origin: qyxxjd/BaseProject
/**
* 返回SIM卡的序列号(IMEI)
* 注意:对于CDMA设备,返回的是一个空值!
*/
public String getSimSerialNumber() {
final String simSerialNumber = mTelephonyManager.getSimSerialNumber();
return TextUtils.isEmpty(simSerialNumber) ? "" : simSerialNumber;
}
代码示例来源:origin: Trumeet/MiPushFramework
@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() {
final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
new CondomOptions().addKit(new NullDeviceIdKit()));
final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
assertTrue(condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE).getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
assertPermission(condom, READ_PHONE_STATE, true);
assertNull(tm.getDeviceId());
if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
assertNull(tm.getImei());
assertNull(tm.getImei(0));
if (SDK_INT >= O) assertNull(tm.getMeid());
if (SDK_INT >= O) assertNull(tm.getMeid(0));
assertNull(tm.getSimSerialNumber());
assertNull(tm.getLine1Number());
assertNull(tm.getSubscriberId());
}
代码示例来源:origin: stackoverflow.com
String getUUID(){
TelephonyManager teleManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String tmSerial = teleManager.getSimSerialNumber();
String tmDeviceId = teleManager.getDeviceId();
String androidId = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
if (tmSerial == null) tmSerial = "1";
if (tmDeviceId== null) tmDeviceId = "1";
if (androidId == null) androidId = "1";
UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDeviceId.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
return uniqueId;
}
代码示例来源:origin: stackoverflow.com
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = ""
+ android.provider.Settings.Secure.getString(context.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;
/*Below line fails on android 4.4 devices sometime so i made the above lines*/
// return Secure.getString(activity.getContentResolver(), Secure.ANDROID_ID);
}
代码示例来源:origin: marzika/Snapprefs
public void createDeviceId() {
if (deviceUuid != null)
return;
final TelephonyManager tm = (TelephonyManager) this.getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// IMEI No.
String imeiNo = TM.getDeviceId();
// IMSI No.
String imsiNo = TM.getSubscriberId();
// SIM Serial No.
String simSerialNo = TM.getSimSerialNumber();
// Android Unique ID
String androidId = System.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
代码示例来源:origin: stackoverflow.com
TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// IMEI No.
String imeiNo = TM.getDeviceId();
// IMSI No.
String imsiNo = TM.getSubscriberId();
// SIM Serial No.
String simSerialNo = TM.getSimSerialNumber();
// Android Unique ID
String androidId = System.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
代码示例来源:origin: stackoverflow.com
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();
String simno = mTelephonyMgr.getSimSerialNumber();
Log.v("", ""+imsi);
Log.v("", ""+imei);
Log.v("", ""+simno);
代码示例来源:origin: stackoverflow.com
TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// IMEI No.
String imeiNo = TM.getDeviceId();
// IMSI No.
String imsiNo = TM.getSubscriberId();
// SIM Serial No.
String simSerialNo = TM.getSimSerialNumber();
// Android Unique ID
String androidId = System.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);
内容来源于网络,如有侵权,请联系作者删除!