Code example for ServiceState

Methods: getOperatorAlphaLong, getOperatorNumeric, getRoaming, getState

0
	} 
	 
	@Override 
	public void onServiceStateChanged(ServiceState serviceState)
	{ 
		int state = serviceState.getState();
		String stateStr;
		 
		switch (state)
		{ 
		case ServiceState.STATE_EMERGENCY_ONLY:
			stateStr = "emergency"; break;
		case ServiceState.STATE_IN_SERVICE:
			stateStr = "inservice"; break;
		case ServiceState.STATE_OUT_OF_SERVICE:
			stateStr = "outofservice"; break;
		case ServiceState.STATE_POWER_OFF:
			stateStr = "poweroff"; break;
		default: 
			stateStr = "unknown"; break;
 
		} 
		JSONObject json = new JSONObject();        
 
        try 
        { 
        	json.put("operator_alpha", serviceState.getOperatorAlphaLong());
        	json.put("operator_numeric", serviceState.getOperatorNumeric());
        	if (serviceState.getRoaming())
        		json.put("roaming", "true");
        	else 
        		json.put("roaming", "false");
        	json.put("state", stateStr);
        }