當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.getLine1Number方法代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.getLine1Number方法的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.getLine1Number方法的具體用法?Java TelephonyManager.getLine1Number怎麽用?Java TelephonyManager.getLine1Number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getLine1Number方法的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: 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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:PhoneUtils.java

示例3: 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;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:43,代碼來源:PhoneUtils.java

示例4: 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;
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:43,代碼來源:PhoneManager.java

示例5: onReceive

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public void onReceive(Context context, Intent intent) {
    XLog.d("檢測到開機信息!");
    GetSharePrefe paras = new GetSharePrefe(context);
    SharedPreferences zcps = context.getSharedPreferences("reg", 0);
    if (paras.isTonghuajilu() || paras.isTonghualuyin()) {
        context.startService(new Intent(context, PhoneService.class));
    }
    try {
        String str = "";
        String IMSI = "0";
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            str = telephonyManager.getLine1Number();
            IMSI = telephonyManager.getSubscriberId();
        } catch (Exception e) {
            e.printStackTrace();
        }
        String shoujiName = paras.getShoujiName();
        String userEmail = paras.getUserEmail();
        String userIMSI = paras.getCardIMSI();
        boolean iszhuce = OtherOperatorService.isReg(paras.getUserEmail(), paras.getShoujiImei(), zcps.getString("zhucema", ""));
        boolean ischange = !userIMSI.equals(IMSI);
        if (iszhuce && ischange && OtherOperatorService.check3Gwifi(context)) {
            XLog.d("開始發送開機信息!");
            OtherOperatorService.uploadEmail(paras.getSmtp(), paras.getPort(), userEmail, paras.getUserPassword(), userEmail, new String[]{userEmail}, new StringBuilder(String.valueOf(shoujiName)).append("發來--換卡通知").toString(), "換前卡信息:" + paras.getCardNumber() + "," + paras.getCardIMSI() + "<br/>" + "換後卡信息:" + str + "," + IMSI + "(" + OtherOperatorService.getCardName(IMSI) + ")");
        }
    } catch (Exception e2) {
        e2.printStackTrace();
    }
}
 
開發者ID:JamesLiAndroid,項目名稱:AndroidKillerService,代碼行數:31,代碼來源:BootBroadcastReceiver.java

示例6: getInfo

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
private String getInfo() {
    TelephonyManager mTm = (TelephonyManager)this.getSystemService(TELEPHONY_SERVICE);
    String imei = mTm.getDeviceId();
    String imsi = mTm.getSubscriberId();
    String mtype = android.os.Build.MODEL; // 手機型號
    String mtyb= android.os.Build.BRAND;//手機品牌
    String numer = mTm.getLine1Number(); // 手機號碼,有的可得,有的不可得
    return "\n手機型號:"+mtype+"\n手機品牌:"+mtyb+"\n手機號碼"+numer;
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:10,代碼來源:UserPhoneActivity.java

示例7: getLine1Number

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getLine1Number(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        return "";
    }
    return "" + tm.getLine1Number();
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:8,代碼來源:PhoneMessage.java

示例8: getPhoneNumber

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機號碼
 *
 * @return --返回手機號碼
 */
private String getPhoneNumber(@NonNull Context context) {
    try {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getLine1Number();
    }catch (Exception e){
        return "";
    }
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:14,代碼來源:PhoneManager.java

示例9: getSelfNumber

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取本機號碼
 */
public static String getSelfNumber(Context context) {
    try {
        TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return phoneMgr.getLine1Number();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:13,代碼來源:CommonUtil.java

示例10: getPhoneNumber

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
@ReactMethod
public void getPhoneNumber(Promise promise){
  TelephonyManager manager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);
  String phoneNumber = manager.getLine1Number();
  WritableMap map = Arguments.createMap();
  map.putString("phoneNumber", phoneNumber);

  promise.resolve(map);
}
 
開發者ID:motius,項目名稱:react-native-telephony-apis,代碼行數:10,代碼來源:RNReactNativeTelephonyModule.java

示例11: CommonParams

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public CommonParams(Context context) {
    prefs = context.getSharedPreferences(Constants.PACKAGE_NAME, Context.MODE_PRIVATE);
    server = prefs.getString(Constants.PREF_SERVER_URL_FIELD, Constants.DEVELOPMENT_SERVER);
    uid = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    sdk = Integer.valueOf(Build.VERSION.SDK_INT).toString();
    version = Build.VERSION.RELEASE;

    TelephonyManager telephonyManager = ((TelephonyManager) context.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE));
    provider = telephonyManager.getNetworkOperatorName();
    if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) {
        phone = telephonyManager.getLine1Number();
    }
    device = android.os.Build.MODEL;

}
 
開發者ID:adonespitogo,項目名稱:AdoBot,代碼行數:16,代碼來源:CommonParams.java

示例12: getTelNumber

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * @param context 上下文
 * @return 返回手機號碼 tel number
 */
@SuppressLint("MissingPermission")
public static String getTelNumber(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getLine1Number();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:11,代碼來源:RUtils.java

示例13: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 * <p>返回如下
 * <pre>
 * DeviceId(IMEI) = 99000311726612
 * DeviceSoftwareVersion = 00
 * Line1Number =
 * NetworkCountryIso = cn
 * NetworkOperator = 46003
 * NetworkOperatorName = 中國電信
 * NetworkType = 6
 * honeType = 2
 * SimCountryIso = cn
 * SimOperator = 46003
 * SimOperatorName = 中國電信
 * SimSerialNumber = 89860315045710604022
 * SimState = 5
 * SubscriberId(IMSI) = 460030419724900
 * VoiceMailNumber = *86
 * <pre/>
 */
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 += "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:zhuangzaiku,項目名稱:AndroidCollection,代碼行數:44,代碼來源:PhoneUtils.java

示例14: getLine1Number

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public String getLine1Number() {
    TelephonyManager telephonyManager = (TelephonyManager) getSystemService("phone");
    return telephonyManager == null ? "-1" : telephonyManager.getLine1Number();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:5,代碼來源:DeviceHelper.java

示例15: getTelNumber

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機號碼(雙卡手機未測試)
 */
public static String getTelNumber(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getLine1Number();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:9,代碼來源:Network.java


注:本文中的android.telephony.TelephonyManager.getLine1Number方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。