List of usage examples for android.telephony TelephonyManager DATA_CONNECTING
int DATA_CONNECTING
To view the source code for android.telephony TelephonyManager DATA_CONNECTING.
Click Source Link
From source file:com.karpenstein.signalmon.SignalMonitorActivity.java
/** Called when the activity is first created. */ @Override//from ww w.j a v a 2 s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get the UI textOut = (TextView) findViewById(R.id.textOut); // Get the telephony manager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // Create a new PhoneStateListener listener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { String dirString = "N/A"; switch (direction) { case TelephonyManager.DATA_ACTIVITY_NONE: dirString = "DATA_ACTIVITY_NONE"; break; case TelephonyManager.DATA_ACTIVITY_IN: dirString = "DATA_ACTIVITY_IN"; break; case TelephonyManager.DATA_ACTIVITY_OUT: dirString = "DATA_ACTIVITY_OUT"; break; case TelephonyManager.DATA_ACTIVITY_INOUT: dirString = "DATA_ACTIVITY_INOUT"; break; case TelephonyManager.DATA_ACTIVITY_DORMANT: dirString = "DATA_ACTIVITY_DORMANT"; break; } textOut.append(dirString + "\n"); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { textOut.append(signalStrength.toString() + "\n"); } @Override public void onDataConnectionStateChanged(int state, int networkType) { String stateString = "N/A"; String netTypString = "N/A"; switch (state) { case TelephonyManager.DATA_CONNECTED: stateString = "DATA_CONNECTED"; break; case TelephonyManager.DATA_CONNECTING: stateString = "DATA_CONNECTING"; break; case TelephonyManager.DATA_DISCONNECTED: stateString = "DATA_DISCONNECTED"; break; case TelephonyManager.DATA_SUSPENDED: stateString = "DATA_SUSPENDED"; break; } switch (networkType) { case TelephonyManager.NETWORK_TYPE_1xRTT: netTypString = "NETWORK_TYPE_1xRTT"; break; case TelephonyManager.NETWORK_TYPE_CDMA: netTypString = "NETWORK_TYPE_CDMA"; break; case TelephonyManager.NETWORK_TYPE_EDGE: netTypString = "NETWORK_TYPE_EDGE"; break; case TelephonyManager.NETWORK_TYPE_EVDO_0: netTypString = "NETWORK_TYPE_EVDO_0"; break; case TelephonyManager.NETWORK_TYPE_EVDO_A: netTypString = "NETWORK_TYPE_EVDO_A"; break; case TelephonyManager.NETWORK_TYPE_GPRS: netTypString = "NETWORK_TYPE_GPRS"; break; case TelephonyManager.NETWORK_TYPE_HSDPA: netTypString = "NETWORK_TYPE_HSDPA"; break; case TelephonyManager.NETWORK_TYPE_HSPA: netTypString = "NETWORK_TYPE_HSPA"; break; case TelephonyManager.NETWORK_TYPE_HSUPA: netTypString = "NETWORK_TYPE_HSUPA"; break; case TelephonyManager.NETWORK_TYPE_IDEN: netTypString = "NETWORK_TYPE_IDE"; break; case TelephonyManager.NETWORK_TYPE_UMTS: netTypString = "NETWORK_TYPE_UMTS"; break; case TelephonyManager.NETWORK_TYPE_UNKNOWN: netTypString = "NETWORK_TYPE_UNKNOWN"; break; } textOut.append(String.format("onDataConnectionStateChanged: %s; %s\n", stateString, netTypString)); } }; // Register the listener with the telephony manager telephonyManager.listen(listener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY); // start the NetServerService startService(new Intent(this, NetServerService.class)); }
From source file:com.fallahpoor.infocenter.fragments.SimFragment.java
private String getDataConnectionState(TelephonyManager telephonyManager) { int dataStateInt = telephonyManager.getDataState(); String dataStateStr;/*from w ww . j a va 2 s. c om*/ switch (dataStateInt) { case TelephonyManager.DATA_CONNECTED: dataStateStr = getString(R.string.sim_sub_item_data_connected); break; case TelephonyManager.DATA_CONNECTING: dataStateStr = getString(R.string.sim_sub_item_data_connecting); break; case TelephonyManager.DATA_DISCONNECTED: dataStateStr = getString(R.string.sim_sub_item_data_disconnected); break; case TelephonyManager.DATA_SUSPENDED: dataStateStr = getString(R.string.sim_sub_item_data_suspended); break; default: dataStateStr = getString(R.string.unknown); } return dataStateStr; }
From source file:com.ultrafunk.network_info.receiver.MobileDataStatusReceiver.java
@Override protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions) { if (isMobileDataEnabled && isMobileOutOfService) { setStateColor(context, remoteViews, STATE_ON); remoteViews.setTextViewText(R.id.mobileNameTextView, context.getString(R.string.mobile_data)); remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled); remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE); remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.no_service)); remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE); return;//from w w w .j a v a2 s. c om } if (dataState == TelephonyManager.DATA_DISCONNECTED) { remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE); remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE); if (isMobileDataEnabled && !isAirplaneModeOn) { setStateColor(context, remoteViews, STATE_ON); remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider); remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled); remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.not_connected)); remoteViews.setTextColor(R.id.mobileInfoBottomTextView, ContextCompat.getColor(context, R.color.medium_gray)); remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes())); } else { setStateColor(context, remoteViews, STATE_OFF); remoteViews.setTextViewText(R.id.mobileNameTextView, isAirplaneModeOn ? context.getString(R.string.mobile_data) : networkOperatorAndServiceProvider); remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_off); if (isAirplaneModeOn) { remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.flight_mode)); remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE); } else { remoteViews.setTextViewText(R.id.mobileInfoTopTextView, MobileDataUtils.getNetworkTypeString(telephonyManager.getNetworkType()) + (isDataRoaming ? " - " + context.getString(R.string.roaming) : "")); remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes())); } } } else { setStateColor(context, remoteViews, STATE_ON); remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider); remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_on); remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE); remoteViews.setTextViewText(R.id.mobileInfoTopTextView, MobileDataUtils.getNetworkTypeString(telephonyManager.getNetworkType()) + (isDataRoaming ? " - " + context.getString(R.string.roaming) : "")); remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE); boolean isConnecting = ((dataState == TelephonyManager.DATA_CONNECTING) || NetworkStateService.isWaitingForDataUsage()); remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, isConnecting ? context.getString(R.string.connecting) : MobileDataUtils.getDataUsageString(context, dataUsageBytes)); } }
From source file:riddimon.android.asianetautologin.HttpUtils.java
/** * Uses TelephonyManager and WifiManager to check for network connectivity. * Also incorporates CONNECTING state for retry scenarios. * @param context//from w w w . j a v a 2 s . co m * @return ConnectionStatus */ public ConnectionStatus isConnectedOLD(Context context) { boolean data = false, wifi = false; boolean data_connecting = false, wifi_connecting = false; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int ds = tm.getDataState(); int ws = wm.getWifiState(); switch (ds) { case TelephonyManager.DATA_CONNECTED: data = true; break; case TelephonyManager.DATA_CONNECTING: data_connecting = true; default: data = false; data_connecting = false; } switch (ws) { case WifiManager.WIFI_STATE_ENABLING: wifi_connecting = true; case WifiManager.WIFI_STATE_DISABLING: case WifiManager.WIFI_STATE_DISABLED: case WifiManager.WIFI_STATE_UNKNOWN: wifi = false; break; case WifiManager.WIFI_STATE_ENABLED: WifiInfo wi = wm.getConnectionInfo(); if (wi != null) wifi = true; break; } if (wifi && data) return ConnectionStatus.BOTH_CONNECTED; else if (wifi && data_connecting) return ConnectionStatus.WIFI_CONNECTED; else if (data && wifi_connecting) return ConnectionStatus.DATA_CONNECTED; else if (wifi_connecting || data_connecting) return ConnectionStatus.CONNECTING; return ConnectionStatus.NO_CONNECTION; }
From source file:org.restcomm.app.qoslib.Utils.QosInfo.java
public String getStateName(int state) { switch (state) { case TelephonyManager.DATA_CONNECTED: return "connected"; case TelephonyManager.DATA_CONNECTING: return "connecting"; case TelephonyManager.DATA_DISCONNECTED: return "disconnected"; case TelephonyManager.DATA_SUSPENDED: return "suspended"; }//from w ww . j a v a2 s. c o m return "-"; }