本文整理汇总了Java中android.telephony.TelephonyManager.getPhoneType方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getPhoneType方法的具体用法?Java TelephonyManager.getPhoneType怎么用?Java TelephonyManager.getPhoneType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.TelephonyManager
的用法示例。
在下文中一共展示了TelephonyManager.getPhoneType方法的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>
*/
@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;
}
示例2: getUserCountry
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getUserCountry(Context context) {
try {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final String simCountry = tm.getSimCountryIso();
if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
Timber.i(simCountry);
return simCountry.toLowerCase(Locale.US);
} else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
String networkCountry = tm.getNetworkCountryIso();
if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
return networkCountry.toLowerCase(Locale.US);
}
}
} catch (Exception e) {
Timber.i(e.getMessage());
}
return null;
}
示例3: 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;
}
示例4: invalidate
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@Override
public ControllerParent<PhoneShield> invalidate(
com.integreight.onesheeld.shields.ControllerParent.SelectionAction selectionAction,
boolean isToastable) {
this.selectionAction = selectionAction;
addRequiredPremission(Manifest.permission.CALL_PHONE);
addRequiredPremission(Manifest.permission.READ_PHONE_STATE);
TelephonyManager tm = (TelephonyManager) getApplication()
.getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
// No calling functionality
if (this.selectionAction != null) {
this.selectionAction.onFailure();
if (isToastable)
activity.showToast(activity.getString(R.string.phone_your_device_doesnt_have_a_sim_card));
}
} else {
if (checkForPermissions()) {
// calling functionality
if (this.selectionAction != null) {
this.selectionAction.onSuccess();
}
}else{
if (this.selectionAction != null) {
this.selectionAction.onFailure();
}
}
}
return super.invalidate(selectionAction, isToastable);
}
示例5: hasTelephonySupport
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean hasTelephonySupport(Context con) {
// returns false if device has no phone radio (no telephony support)
if (mHasTelephonySupport != null) return mHasTelephonySupport;
try {
TelephonyManager tm = (TelephonyManager) con.getSystemService(
Context.TELEPHONY_SERVICE);
mHasTelephonySupport = (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE);
return mHasTelephonySupport;
} catch (Throwable t) {
mHasTelephonySupport = null;
return false;
}
}
示例6: invalidate
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@Override
public ControllerParent<SmsShield> invalidate(
com.integreight.onesheeld.shields.ControllerParent.SelectionAction selectionAction,
boolean isToastable) {
this.selectionAction = selectionAction;
TelephonyManager tm = (TelephonyManager) getApplication()
.getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
// No calling functionality
if (this.selectionAction != null) {
this.selectionAction.onFailure();
if (isToastable)
activity.showToast(activity.getString(R.string.sms_your_device_doesnt_have_a_sim_card));
}
} else {
addRequiredPremission(Manifest.permission.READ_SMS);
addRequiredPremission(Manifest.permission.SEND_SMS);
addRequiredPremission(Manifest.permission.RECEIVE_SMS);
if (checkForPermissions()) {
// calling functionality
if (this.selectionAction != null) {
this.selectionAction.onSuccess();
}
}else{
if (this.selectionAction != null) {
this.selectionAction.onFailure();
}
}
}
return super.invalidate(selectionAction, isToastable);
}
示例7: getMtkTeleInfo2
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* MTK Phone.
*
* 获取 MTK 神机的双卡 IMSI、IMSI 信息
*/
public static TeleInfo getMtkTeleInfo2(Context context) {
TeleInfo teleInfo = new TeleInfo();
try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> phone = Class.forName("com.android.internal.telephony.Phone");
Field fields1 = phone.getField("GEMINI_SIM_1");
fields1.setAccessible(true);
int simId_1 = (Integer) fields1.get(null);
Field fields2 = phone.getField("GEMINI_SIM_2");
fields2.setAccessible(true);
int simId_2 = (Integer) fields2.get(null);
Method getDefault = TelephonyManager.class.getMethod("getDefault", int.class);
TelephonyManager tm1 = (TelephonyManager) getDefault.invoke(tm, simId_1);
TelephonyManager tm2 = (TelephonyManager) getDefault.invoke(tm, simId_2);
String imsi_1 = tm1.getSubscriberId();
String imsi_2 = tm2.getSubscriberId();
teleInfo.imsi_1 = imsi_1;
teleInfo.imsi_2 = imsi_2;
String imei_1 = tm1.getDeviceId();
String imei_2 = tm2.getDeviceId();
teleInfo.imei_1 = imei_1;
teleInfo.imei_2 = imei_2;
int phoneType_1 = tm1.getPhoneType();
int phoneType_2 = tm2.getPhoneType();
teleInfo.phoneType_1 = phoneType_1;
teleInfo.phoneType_2 = phoneType_2;
} catch (Exception e) {
e.printStackTrace();
}
Log.i(TAG, "MTK2: " + teleInfo);
return teleInfo;
}
示例8: initialize
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private static void initialize(Context context) {
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
sIsPhone = (telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE);
//sIsSipPhone = sIsPhone && SipManager.isVoipSupported(context);
Intent pIntent = getPriviledgedIntent("123");
callIntents = getPossibleActivities(context, pIntent);
PackageManager pm = context.getPackageManager();
defaultCallIntent = pm.resolveActivity(pIntent, PackageManager.MATCH_DEFAULT_ONLY);
sIsInitialized = true;
}
示例9: getTowerValues
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private int[] getTowerValues() {
// Find new values
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// Find the location
if (tm == null) {
popupMsg("Could not get TelephonyManager");
return null;
}
int phoneType = tm.getPhoneType();
if (phoneType != TelephonyManager.PHONE_TYPE_CDMA) {
popupMsg("Only CDMA is supported");
return null;
}
CellLocation cl = tm.getCellLocation();
if (cl == null) {
popupMsg("Could not get Cell Location");
return null;
}
if (!(cl instanceof CdmaCellLocation)) {
popupMsg("Cell Location is is not a CdmaCellLocation class");
return null;
}
CdmaCellLocation cdmacl = (CdmaCellLocation) cl;
int lat = NetworkActivity.locToGoogle(cdmacl.getBaseStationLatitude());
int lon = NetworkActivity.locToGoogle(cdmacl.getBaseStationLongitude());
int nid = cdmacl.getNetworkId();
int sid = cdmacl.getSystemId();
int bid = cdmacl.getBaseStationId();
Log.d(TAG, " New values: " + " lat=" + lat + " lon=" + lon + " nid="
+ nid + " sid=" + sid + " bid=" + bid);
return new int[] { lat, lon, nid, sid, bid };
}
示例10: CellTracker
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public CellTracker(Context context, SignalStrengthTracker sst) {
this.context = context;
this.signalStrengthTracker = sst;
// Creating tinydb here to avoid: "TinyDb tinydb = new TinyDb(context);"
// every time we need to use tinydb in this class.
tinydb = TinyDB.getInstance();
// TelephonyManager provides system details
tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// Shared Preferences
prefs = context.getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
prefs.registerOnSharedPreferenceChangeListener(this);
loadPreferences();
setNotification();
PHONE_TYPE = tm.getPhoneType(); // PHONE_TYPE_GSM/CDMA/SIP/NONE
dbHelper = new AIMSICDDbAdapter(context);
// Remove all but the last DBi_bts entry, after:
// (a) starting CellTracker for the first time or
// (b) having cleared the preferences.
// Subsequent runs are prevented by a hidden boolean preference. See: loadPreferences()
if (!CELL_TABLE_CLEANSED) {
dbHelper.cleanseCellTable();
SharedPreferences.Editor prefsEditor;
prefsEditor = prefs.edit();
prefsEditor.putBoolean(context.getString(R.string.pref_cell_table_cleansed), true); // set to true
prefsEditor.apply();
}
mDevice.refreshDeviceInfo(tm, context); // Telephony Manager
mMonitorCell = new Cell();
}
示例11: getMtkTeleInfo2
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* MTK Phone.
* <p>
* 获取 MTK 神机的双卡 IMSI、IMSI 信息
*/
public static TeleInfo getMtkTeleInfo2(Context context) {
TeleInfo teleInfo = new TeleInfo();
try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> phone = Class.forName("com.android.internal.telephony.Phone");
Field fields1 = phone.getField("GEMINI_SIM_1");
fields1.setAccessible(true);
int simId_1 = (Integer) fields1.get(null);
Field fields2 = phone.getField("GEMINI_SIM_2");
fields2.setAccessible(true);
int simId_2 = (Integer) fields2.get(null);
Method getDefault = TelephonyManager.class.getMethod("getDefault", int.class);
TelephonyManager tm1 = (TelephonyManager) getDefault.invoke(tm, simId_1);
TelephonyManager tm2 = (TelephonyManager) getDefault.invoke(tm, simId_2);
String imsi_1 = tm1.getSubscriberId();
String imsi_2 = tm2.getSubscriberId();
teleInfo.imsi_1 = imsi_1;
teleInfo.imsi_2 = imsi_2;
String imei_1 = tm1.getDeviceId();
String imei_2 = tm2.getDeviceId();
teleInfo.imei_1 = imei_1;
teleInfo.imei_2 = imei_2;
int phoneType_1 = tm1.getPhoneType();
int phoneType_2 = tm2.getPhoneType();
teleInfo.phoneType_1 = phoneType_1;
teleInfo.phoneType_2 = phoneType_2;
} catch (Exception e) {
e.printStackTrace();
}
ViseLog.i("MTK2: " + teleInfo);
return teleInfo;
}
示例12: getSpreadtrumTeleInfo
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* Spreadtrum Phone.
* <p>
* 获取 展讯 神机的双卡 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();
}
ViseLog.i("Spreadtrum: " + teleInfo);
return teleInfo;
}
示例13: isPhoneAvailable
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean isPhoneAvailable(Context context) {
if(context == null){
throw new IllegalArgumentException("Context cannot be null");
}
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager != null && telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
示例14: isCDMA
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private static final boolean isCDMA(Context context) {
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephony != null && telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
}
示例15: isPhone
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* 判断设备是否是手机
*/
public static boolean isPhone(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}