Android ServiceState - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ServiceState class.

This code example shows how to use the following methods:getState
     */ 
    public void registerForNetworkAttached(Handler h, int what, Object obj) {
        Registrant r = new Registrant(h, what, obj);
 
        mNetworkAttachedRegistrants.add(r);
        if (ss.getState() == ServiceState.STATE_IN_SERVICE) {
            r.notifyRegistrant();
        } 
    } 
    public void unregisterForNetworkAttached(Handler h) {
        mNetworkAttachedRegistrants.remove(h);
    } 
 
    /** 
     * Registration point for transition into packet service restricted zone. 
     * @param h handler to notify 
     * @param what what code of message when delivered 
     * @param obj placed in Message.obj 
     */ 
    public void registerForPsRestrictedEnabled(Handler h, int what, Object obj) {
6
CodeRank
This code example shows how to use the following methods:getOperatorAlphaLong, getState
	static class PhoneState extends PhoneStateListener {
		public int state = 0;
		public int strength = 0;
		 
		public void onServiceStateChanged(ServiceState serviceState){
			Log.d(TAG, "Service State changed to: " + serviceState.getState() + " -- " + serviceState.getOperatorAlphaLong());
			state = serviceState.getState();
		} 
		 
		public void	onSignalStrengthsChanged(SignalStrength signalStrength){
			//Log.d(TAG, "Signal strength changed to: " + signalStrength.getGsmSignalStrength()); 
			strength = signalStrength.getGsmSignalStrength();
		} 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getOperatorAlphaLong, getOperatorNumeric, getRoaming, getState
	} 
	 
	@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;

5
CodeRank
This code example shows how to use the following methods:getOperatorAlphaLong, getOperatorAlphaShort, getState
		 
	} 
	 
	@Override 
	public void onServiceStateChanged (ServiceState serviceState){
		Log.e("Operador:", serviceState.getOperatorAlphaLong()+"");
		Log.e("Operador2:", serviceState.getOperatorAlphaShort());
		switch (serviceState.getState()) {
		case ServiceState.STATE_IN_SERVICE:
			Log.e("Estado:", "En Servicio");
			break; 
 
		case ServiceState.STATE_OUT_OF_SERVICE:
			Log.e("Estado:", "Fuera de Servicio");
			break; 
		} 
	} 
	 
	@Override 
	public void onCellLocationChanged (CellLocation location){
5
CodeRank
This code example shows how to use the following methods:getState
    public boolean isConnected() { 
        return isWiFiConnected() || isMobileConnected(); 
    } 
 
    public boolean isRadioOff() { 
        ServiceState serviceState = new ServiceState();
        return serviceState.getState() == ServiceState.STATE_POWER_OFF;
    } 
 
 
} 
5
CodeRank
This code example shows how to use the following methods:setStateOutOfService
    @Override 
    public void notifyServiceState(Phone sender) {
        ServiceState ss = sender.getServiceState();
        int subscription = sender.getSubscription();
        if (ss == null) {
            ss = new ServiceState();
            ss.setStateOutOfService();
        } 
        try { 
            mMSimRegistry.notifyServiceState(ss, subscription);
        } catch (RemoteException ex) {
            // system process is dead 
        } 
    } 
 
    @Override 
    public void notifySignalStrength(Phone sender) {
        int subscription = sender.getSubscription();
        try { 
            mMSimRegistry.notifySignalStrength(sender.getSignalStrength(), subscription);
5
CodeRank
This code example shows how to use the following methods:
 
    private int mCallState = TelephonyManager.CALL_STATE_IDLE;
 
    private String mCallIncomingNumber = "";
 
    private ServiceState mServiceState = new ServiceState();
 
    private SignalStrength mSignalStrength = new SignalStrength();
 
    private boolean mMessageWaiting = false;
 
    private boolean mCallForwarding = false;
 
    private int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE;
 
    private int mDataConnectionState = TelephonyManager.DATA_CONNECTED;
 
    private boolean mDataConnectionPossible = false;
 
    private String mDataConnectionReason = "";
5
CodeRank
This code example shows how to use the following methods:getState, setState
	} 
    } 
 
    @Override 
    public void onServiceStateChanged(ServiceState serviceState) {
	switch (serviceState.getState()) {
	case ServiceState.STATE_IN_SERVICE:
	    Log.i(TAG, "MyPhoneStateListener->onServiceStateChanged() -> STATE_IN_SERVICE");
	    serviceState.setState(ServiceState.STATE_IN_SERVICE);
	    break; 
	case ServiceState.STATE_OUT_OF_SERVICE:
	    Log.i(TAG, "MyPhoneStateListener->onServiceStateChanged() -> STATE_OUT_OF_SERVICE");
	    serviceState.setState(ServiceState.STATE_OUT_OF_SERVICE);
	    break; 
	case ServiceState.STATE_EMERGENCY_ONLY:
	    Log.i(TAG, "MyPhoneStateListener->onServiceStateChanged() -> STATE_EMERGENCY_ONLY");
	    serviceState.setState(ServiceState.STATE_EMERGENCY_ONLY);
	    break; 
	case ServiceState.STATE_POWER_OFF:
	    Log.i(TAG, "MyPhoneStateListener->onServiceStateChanged() -> STATE_POWER_OFF");

5
CodeRank
This code example shows how to use the following methods:getState
     */ 
    public void registerForNetworkAttached(Handler h, int what, Object obj) { 
        Registrant r = new Registrant(h, what, obj); 
 
        mNetworkAttachedRegistrants.add(r); 
        if (ss.getState() == ServiceState.STATE_IN_SERVICE) { 
            r.notifyRegistrant(); 
        } 
    } 
    public void unregisterForNetworkAttached(Handler h) { 
        mNetworkAttachedRegistrants.remove(h); 
    } 
 
    /** 
     * Registration point for transition into packet service restricted zone. 
     * @param h handler to notify 
     * @param what what code of message when delivered 
     * @param obj placed in Message.obj 
     */ 
    public void registerForPsRestrictedEnabled(Handler h, int what, Object obj) { 
3
CodeRank
This code example shows how to use the following methods:getState
		} 
 
		@Override 
		public void onServiceStateChanged(ServiceState serviceState) { 
			String serviceStateString = "UNKNOWN"; 
			switch (serviceState.getState()) { 
			case ServiceState.STATE_IN_SERVICE: 
				serviceStateString = "IN SERVICE"; 
				break; 
			case ServiceState.STATE_EMERGENCY_ONLY: 
				serviceStateString = "EMERGENCY ONLY"; 
				break; 
			case ServiceState.STATE_OUT_OF_SERVICE: 
				serviceStateString = "OUT OF SERVICE"; 
				break; 
			case ServiceState.STATE_POWER_OFF: 
				serviceStateString = "POWER OFF"; 
				break; 
			default: 
 
3
CodeRank

Related Android ServiceState Questions & Answers:

See Code Examples for Android ServiceState Methods: