本文整理汇总了Java中android.telephony.TelephonyManager.getDeviceId方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getDeviceId方法的具体用法?Java TelephonyManager.getDeviceId怎么用?Java TelephonyManager.getDeviceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.TelephonyManager
的用法示例。
在下文中一共展示了TelephonyManager.getDeviceId方法的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>
*/
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;
}
示例2: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imei = (telephonyManager == null ? null : telephonyManager.getDeviceId());
return imei == null ? "" : imei;
}
示例3: f
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public String f() {
TelephonyManager telephonyManager = (TelephonyManager) this.b.getSystemService("phone");
if (telephonyManager == null) {
}
try {
if (bt.a(this.b, "android.permission.READ_PHONE_STATE")) {
return telephonyManager.getDeviceId();
}
return null;
} catch (Exception e) {
return null;
}
}
示例4: getSpreadtrumTeleInfo
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* Spreadtrum Phone.
*
* 获取 展讯 神机的双卡 IMSI、IMSI 信息
*/
public static TeleInfo getSpreadtrumTeleInfo(Context context) {
TeleInfo teleInfo = new TeleInfo();
try {
TelephonyManager tm1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imsi_1 = tm1.getSubscriberId();
String imei_1 = tm1.getDeviceId();
int phoneType_1 = tm1.getPhoneType();
teleInfo.imsi_1 = imsi_1;
teleInfo.imei_1 = imei_1;
teleInfo.phoneType_1 = phoneType_1;
Class<?> phoneFactory = Class.forName("com.android.internal.telephony.PhoneFactory");
Method getServiceName = phoneFactory.getMethod("getServiceName", String.class, int.class);
getServiceName.setAccessible(true);
String spreadTmService = (String) getServiceName.invoke(phoneFactory, Context.TELEPHONY_SERVICE, 1);
TelephonyManager tm2 = (TelephonyManager) context.getSystemService(spreadTmService);
String imsi_2 = tm2.getSubscriberId();
String imei_2 = tm2.getDeviceId();
int phoneType_2 = tm2.getPhoneType();
teleInfo.imsi_2 = imsi_2;
teleInfo.imei_2 = imei_2;
teleInfo.phoneType_2 = phoneType_2;
} catch (Exception e) {
e.printStackTrace();
}
Log.i(TAG, "Spreadtrum: " + teleInfo);
return teleInfo;
}
示例5: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取IMEI
* 手机唯一设别号码
*/
public static String getIMEI(Context context) {
if (null == context) {
return null;
}
String imei = null;
try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
imei = tm.getDeviceId();
} catch (Exception e) {
}
return imei;
}
示例6: getDeviceIDFromSystem
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getDeviceIDFromSystem(Context context) {
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String deviceID = null;
if(tm != null) {
try {
deviceID = tm.getDeviceId();
} catch (Exception e) {
Log.e(TAG, "getPhoneIMEIFromTelephony: no phone imei", e);
}
}
return deviceID;
}
示例7: getDeviceIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取设备号
*
* @param context
* @return
*/
public static String getDeviceIMEI(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager == null || TextUtils.isEmpty(telephonyManager.getDeviceId())) {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
} else {
return telephonyManager.getDeviceId();
}
}
示例8: getImei
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public final static String getImei(Context context) {
if (context != null) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
try {
if (tm != null && !TextUtils.isEmpty(tm.getDeviceId())) {
return tm.getDeviceId();
}
} catch (Exception e) {
}
}
return DEFAULT_IMEI;
}
示例9: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private String getIMEI(Context context)
{
String szDeviceId="null";
try{
TelephonyManager operator = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String szTempDeviceId = operator.getDeviceId();
int nCount = 0;
while ( ((szTempDeviceId == null) || (szTempDeviceId.equals("")) || (szTempDeviceId.equals("null"))) && (nCount < 5) )
{
szTempDeviceId = operator.getDeviceId();
nCount++;
}
if((szTempDeviceId != null) && (!szTempDeviceId.equals("")) && (!szTempDeviceId.equals("null")))
{
szDeviceId = szTempDeviceId;
}
}
catch(Exception e)
{
e.printStackTrace();
szDeviceId = "null";
}
return szDeviceId;
}
示例10: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return tel.getDeviceId();
}
示例11: getDiviceId
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getDiviceId() {
TelephonyManager TelephonyMgr = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
String szImei = TelephonyMgr.getDeviceId();
String m_szDevIDShort = "35" + //we make this look like a valid IMEI
Build.BOARD.length() % 10 +
Build.BRAND.length() % 10 +
Build.CPU_ABI.length() % 10 +
Build.DEVICE.length() % 10 +
Build.DISPLAY.length() % 10 +
Build.HOST.length() % 10 +
Build.ID.length() % 10 +
Build.MANUFACTURER.length() % 10 +
Build.MODEL.length() % 10 +
Build.PRODUCT.length() % 10 +
Build.TAGS.length() % 10 +
Build.TYPE.length() % 10 +
Build.USER.length() % 10; //13 digits
String m_szAndroidID = Settings.Secure.getString(Utils.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
WifiManager wm = (WifiManager) Utils.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter
m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_szBTMAC = m_BluetoothAdapter.getAddress();
StringBuilder stringBuilder = new StringBuilder();
if (!TextUtils.isEmpty(szImei)) {
stringBuilder.append(szImei);
}
if (!TextUtils.isEmpty(m_szDevIDShort)) {
stringBuilder.append(m_szDevIDShort);
}
if (!TextUtils.isEmpty(m_szAndroidID)) {
stringBuilder.append(m_szAndroidID);
}
if (!TextUtils.isEmpty(m_szWLANMAC)) {
stringBuilder.append(m_szWLANMAC);
}
if (!TextUtils.isEmpty(m_szBTMAC)) {
stringBuilder.append(m_szBTMAC);
}
String m_szLongID = stringBuilder.toString();
Log.i("utils", "手机唯一标识为:" + m_szLongID);
MessageDigest m = null;
try {
m = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
m.update(m_szLongID.getBytes(), 0, m_szLongID.length());
byte p_md5Data[] = m.digest();
String m_szUniqueID = new String();
for (int i = 0; i < p_md5Data.length; i++) {
int b = (0xFF & p_md5Data[i]);
if (b <= 0xF)
m_szUniqueID += "0";
m_szUniqueID += Integer.toHexString(b);
}
m_szUniqueID = m_szUniqueID.toUpperCase();
Log.i("utils", "手机唯一标识MD5为:" + m_szUniqueID);
return m_szUniqueID;
}
示例12: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
return TelephonyMgr.getDeviceId();
}
示例13: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String IMEI = telephonyManager.getDeviceId();
return IMEI;
}
示例14: getIMEI
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI() {
TelephonyManager tel = (TelephonyManager) BaseApplication.context()
.getSystemService(Context.TELEPHONY_SERVICE);
return tel.getDeviceId();
}
示例15: GetDeviceID
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@SimpleFunction(description = "")
public String GetDeviceID() {
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getDeviceId();
}