本文整理匯總了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;
}