本文整理汇总了Java中android.telephony.TelephonyManager.getDataState方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getDataState方法的具体用法?Java TelephonyManager.getDataState怎么用?Java TelephonyManager.getDataState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.TelephonyManager
的用法示例。
在下文中一共展示了TelephonyManager.getDataState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataState
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
String getDataState(TelephonyManager tm) {
int state = tm.getDataState();
mDataState = "undef";
mDataStateShort = "un";
switch (state) {
case TelephonyManager.DATA_DISCONNECTED:
mDataState = "Disconnected";
mDataStateShort = "Di";
break;
case TelephonyManager.DATA_CONNECTING:
mDataState = "Connecting";
mDataStateShort = "Ct";
break;
case TelephonyManager.DATA_CONNECTED:
mDataState = "Connected";
mDataStateShort = "Cd";
break;
case TelephonyManager.DATA_SUSPENDED:
mDataState = "Suspended";
mDataStateShort = "Su";
break;
}
return mDataState;
}
示例2: getNetworkConnectionStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean getNetworkConnectionStatus(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (manager == null) {
return false;
}
NetworkInfo info = manager.getActiveNetworkInfo();
if (info == null) {
return false;
}
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return false;
}
if ((tm.getDataState() == TelephonyManager.DATA_CONNECTED || tm.getDataState() == TelephonyManager.DATA_ACTIVITY_NONE)
&& info.isAvailable()) {
return true;
} else {
return false;
}
}
示例3: isMobileDataEnabledLollipop
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Boolean isMobileDataEnabledLollipop(){
TelephonyManager telephonyService = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
switch (telephonyService.getDataState()) {
case TelephonyManager.DATA_DISCONNECTED:
Log.i(TAG, "DATA_DISCONNECTED");
break;
case TelephonyManager.DATA_CONNECTING:
Log.i(TAG, "DATA_CONNECTING");
break;
case TelephonyManager.DATA_SUSPENDED:
Log.i(TAG, "DATA_SUSPENDED");
break;
case TelephonyManager.DATA_CONNECTED:
Log.i(TAG, "DATA_CONNECTED");
return true;
}
return false;
}
示例4: getNetworkConnectionStatus
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean getNetworkConnectionStatus(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (manager == null) {
return false;
}
NetworkInfo info = manager.getActiveNetworkInfo();
if (info == null) {
return false;
}
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return false;
}
if ((tm.getDataState() == TelephonyManager.DATA_CONNECTED || tm.getDataState() == TelephonyManager.DATA_ACTIVITY_NONE)
&& info.isAvailable()) {
return true;
} else {
return false;
}
}
示例5: getQualcommTeleInfo
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* Qualcomm Phone.
* 获取 高通 神机的双卡 IMSI、IMSI 信息
*/
public static TeleInfo getQualcommTeleInfo(Context context) {
TeleInfo teleInfo = new TeleInfo();
try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> simTMclass = Class.forName("android.telephony.MSimTelephonyManager");
Object sim = context.getSystemService("phone_msim");
int simId_1 = 0;
int simId_2 = 1;
Method getSubscriberId = simTMclass.getMethod("getSubscriberId", int.class);
String imsi_1 = (String) getSubscriberId.invoke(sim, simId_1);
String imsi_2 = (String) getSubscriberId.invoke(sim, simId_2);
teleInfo.imsi_1 = imsi_1;
teleInfo.imsi_2 = imsi_2;
Method getDeviceId = simTMclass.getMethod("getDeviceId", int.class);
String imei_1 = (String) getDeviceId.invoke(sim, simId_1);
String imei_2 = (String) getDeviceId.invoke(sim, simId_2);
teleInfo.imei_1 = imei_1;
teleInfo.imei_2 = imei_2;
Method getDataState = simTMclass.getMethod("getDataState");
int phoneType_1 = tm.getDataState();
int phoneType_2 = (Integer) getDataState.invoke(sim);
teleInfo.phoneType_1 = phoneType_1;
teleInfo.phoneType_2 = phoneType_2;
} catch (Exception e) {
e.printStackTrace();
}
ViseLog.i("Qualcomm: " + teleInfo);
return teleInfo;
}
示例6: getQualcommTeleInfo
import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
* Qualcomm Phone.
* 获取 高通 神机的双卡 IMSI、IMSI 信息
*/
public static TeleInfo getQualcommTeleInfo(Context context) {
TeleInfo teleInfo = new TeleInfo();
try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> simTMclass = Class.forName("android.telephony.MSimTelephonyManager");
Object sim = context.getSystemService("phone_msim");
int simId_1 = 0;
int simId_2 = 1;
Method getSubscriberId = simTMclass.getMethod("getSubscriberId", int.class);
String imsi_1 = (String) getSubscriberId.invoke(sim, simId_1);
String imsi_2 = (String) getSubscriberId.invoke(sim, simId_2);
teleInfo.imsi_1 = imsi_1;
teleInfo.imsi_2 = imsi_2;
Method getDeviceId = simTMclass.getMethod("getDeviceId", int.class);
String imei_1 = (String) getDeviceId.invoke(sim, simId_1);
String imei_2 = (String) getDeviceId.invoke(sim, simId_2);
teleInfo.imei_1 = imei_1;
teleInfo.imei_2 = imei_2;
Method getDataState = simTMclass.getMethod("getDataState");
int phoneType_1 = tm.getDataState();
int phoneType_2 = (Integer) getDataState.invoke(sim);
teleInfo.phoneType_1 = phoneType_1;
teleInfo.phoneType_2 = phoneType_2;
} catch (Exception e) {
e.printStackTrace();
}
Log.i(TAG, "Qualcomm: " + teleInfo);
return teleInfo;
}