List of usage examples for android.telephony TelephonyManager DATA_ACTIVITY_NONE
int DATA_ACTIVITY_NONE
To view the source code for android.telephony TelephonyManager DATA_ACTIVITY_NONE.
Click Source Link
From source file:com.karpenstein.signalmon.NetServerService.java
@Override public void onCreate() { super.onCreate(); try {/*from ww w . j av a 2s . c o m*/ jsonState = new JSONObject(); jsonState.put("dataActivity", TelephonyManager.DATA_ACTIVITY_NONE); } catch (JSONException ex) { Log.d("NetServerService", "Failed to put data activity in the JSONObject"); } // Get the telephony manager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager == null) Log.d("NetServerService", "TelephonyManager was null."); Log.d("NetServerService", "about to create PhoneStateListener"); // Create a new PhoneStateListener psListener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { Log.d("NetServerService", "received onDataActivity message"); try { jsonState.put("dataActivity", direction); } catch (JSONException ex) { } notifyListeners(); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { Log.d("NetServerService", "received onSignalStrength message"); try { jsonState.put("cdmaDbm", signalStrength.getCdmaDbm()); jsonState.put("cdmaEcio", signalStrength.getCdmaEcio()); jsonState.put("evdoDbm", signalStrength.getEvdoDbm()); jsonState.put("evdoEcio", signalStrength.getEvdoEcio()); jsonState.put("evdoSnr", signalStrength.getEvdoSnr()); jsonState.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate()); jsonState.put("gsmSignalStrength", signalStrength.getGsmSignalStrength()); jsonState.put("isGsm", signalStrength.isGsm()); } catch (JSONException ex) { } notifyListeners(); } @Override public void onDataConnectionStateChanged(int state, int networkType) { Log.d("NetServerService", "received onDataConnectionStateChanged message"); try { jsonState.put("connState", state); jsonState.put("netType", networkType); } catch (JSONException ex) { } notifyListeners(); } }; Log.d("NetServerService", "about to call telephonyManager.listen"); // Register the listener with the telephony manager telephonyManager.listen(psListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY); Log.d("NetServerService", "done calling telephonyManager.listen -- exiting onCreate"); }
From source file:com.karpenstein.signalmon.SignalMonitorActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j av a2 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:org.restcomm.app.qoslib.Utils.QosInfo.java
public String getActivityName(int activity) { switch (activity) { case TelephonyManager.DATA_ACTIVITY_DORMANT: return context.getString(R.string.LiveStatus_dormant); case TelephonyManager.DATA_ACTIVITY_IN: return context.getString(R.string.LiveStatus_receiving); case TelephonyManager.DATA_ACTIVITY_OUT: return context.getString(R.string.LiveStatus_sending); case TelephonyManager.DATA_ACTIVITY_INOUT: return context.getString(R.string.LiveStatus_sendrecv); case TelephonyManager.DATA_ACTIVITY_NONE: return context.getString(R.string.LiveStatus_noactivty); }/*from w w w .j a va2 s .c om*/ return "U"; }