当前位置: 首页>>代码示例>>Java>>正文


Java TelephonyManager.getDeviceId方法代码示例

本文整理汇总了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;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:42,代码来源:PhoneUtils.java

示例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;
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:6,代码来源:DeviceUtils.java

示例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;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:f.java

示例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;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:37,代码来源:TelephoneUtil.java

示例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;
}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:17,代码来源:CommonUtils.java

示例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;
}
 
开发者ID:AnnyBaby,项目名称:Mvp-Retrofit-Rxjava-Rxbus,代码行数:13,代码来源:AppInfoUtils.java

示例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();
    }
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:15,代码来源:SystemUtils.java

示例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;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:15,代码来源:NativeHelper.java

示例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;
}
 
开发者ID:quanzhuo,项目名称:prada,代码行数:28,代码来源:Util.java

示例10: getIMEI

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
    TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tel.getDeviceId();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:DeviceUtils.java

示例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;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:79,代码来源:PhoneUtils.java

示例12: getIMEI

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI(Context context) {
    TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
    return TelephonyMgr.getDeviceId();
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:5,代码来源:DeviceInfo.java

示例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;
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:6,代码来源:DeviceUtils.java

示例14: getIMEI

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getIMEI() {
    TelephonyManager tel = (TelephonyManager) BaseApplication.context()
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tel.getDeviceId();
}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:6,代码来源:TDevice.java

示例15: GetDeviceID

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@SimpleFunction(description = "")
public String GetDeviceID() {
    TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getDeviceId();
}
 
开发者ID:OpenSourceAIX,项目名称:ColinTreeIMEI,代码行数:6,代码来源:ColinTreeIMEI.java


注:本文中的android.telephony.TelephonyManager.getDeviceId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。