當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceState類代碼示例

本文整理匯總了Java中android.telephony.ServiceState的典型用法代碼示例。如果您正苦於以下問題:Java ServiceState類的具體用法?Java ServiceState怎麽用?Java ServiceState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServiceState類屬於android.telephony包,在下文中一共展示了ServiceState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServiceStateName

import android.telephony.ServiceState; //導入依賴的package包/類
public String getServiceStateName (int state)
{
    String name = "";
    if (state >= 10)
    {
        name = "roam ";
        if (state == 10)
            return name;
        else
            state = state - 10;
    }
    switch (state)
    {
        case ServiceState.STATE_OUT_OF_SERVICE:
            name += "no service"; break;
        case ServiceState.STATE_EMERGENCY_ONLY:
            name += "911 only"; break;
        case PhoneState.SERVICE_STATE_AIRPLANE:
            name += "airplane"; break;
        case ServiceState.STATE_IN_SERVICE:
            name += "in service"; break;
        case ServiceState.STATE_POWER_OFF:
            name += "power off"; break;
    }
    return name;
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:27,代碼來源:QosInfo.java

示例2: startTrackingFemto

import android.telephony.ServiceState; //導入依賴的package包/類
/**
 * Start FemtoCell detection tracking (For CDMA Devices ONLY!)
 */
public void startTrackingFemto() {

    /* Check if it is a CDMA phone */
    if (device.getPhoneId() != TelephonyManager.PHONE_TYPE_CDMA) {
        Helpers.msgShort(context, context.getString(R.string.femtocell_only_on_cdma_devices));
        return;
    }

    trackingFemtocell = true;
    mPhoneStateListener = new PhoneStateListener() {
        public void onServiceStateChanged(ServiceState s) {
            log.debug(context.getString(R.string.service_state_changed));
            getServiceStateInfo(s);
        }
    };
    tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION);
    tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
    setNotification();
}
 
開發者ID:anticomarley,項目名稱:Android-IMSI-Catcher-Detector,代碼行數:23,代碼來源:CellTracker.java

示例3: getVoiceNetworkType

import android.telephony.ServiceState; //導入依賴的package包/類
public static int getVoiceNetworkType (ServiceState serviceState)
{
    Method m = null;
    try {
        // Java reflection to gain access to TelephonyManager's
        // ITelephony getter
        Class c = Class.forName(serviceState.getClass().getName());
        Method mI = c.getDeclaredMethod("getRilVoiceRadioTechnology");
        mI.setAccessible(true);
        int voiceTechRil = (Integer)mI.invoke(serviceState);
        int voiceTech = PhoneState.rilRadioTechnologyToNetworkType(voiceTechRil);
        return voiceTech;
    }
    catch (Exception e)
    {
        String s = e.toString();
        //LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "getVoiceNetworkType", "exception", e);
    }
    return -1;
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:21,代碼來源:PhoneState.java

示例4: onServiceStateChanged

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onServiceStateChanged (ServiceState serviceState) {
    super.onServiceStateChanged(serviceState);

    PPApplication.logE("PhoneStateScanner.onServiceStateChanged", "telephonyManager=" + telephonyManager);
    CallsCounter.logCounter(context, "PhoneStateScanner.onServiceStateChanged", "PhoneStateScanner_onServiceStateChanged");

    getRegisteredCell();

    if (registeredCell != Integer.MAX_VALUE) {
        DatabaseHandler db = DatabaseHandler.getInstance(context);
        db.updateMobileCellLastConnectedTime(registeredCell, lastConnectedTime);
    }

    doAutoRegistration();
    sendBroadcast();
}
 
開發者ID:henrichg,項目名稱:PhoneProfilesPlus,代碼行數:18,代碼來源:PhoneStateScanner.java

示例5: onServiceStateChanged

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState)
{
	switch (serviceState.getState())
	{
		case ServiceState.STATE_EMERGENCY_ONLY:
		case ServiceState.STATE_OUT_OF_SERVICE:
			NetworkStateService.setMobileOutOfService(true);
			LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
			break;

		default:
			{
				NetworkStateService.setMobileOutOfService(false);

				// If the device is network roaming but mobile data roaming is disabled, this
				// broadcast is necessary to properly update the widget on service state changes.
				if ((serviceState.getState() == ServiceState.STATE_IN_SERVICE) && serviceState.getRoaming())
					LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
			}
			break;
	}
}
 
開發者ID:ultrafunk,項目名稱:NetInfo,代碼行數:24,代碼來源:MobileDataStateListener.java

示例6: getServiceState

import android.telephony.ServiceState; //導入依賴的package包/類
/**
 * Get the service state
 * 
 * @see ServiceState#STATE_EMERGENCY_ONLY
 * @see ServiceState#STATE_IN_SERVICE
 * @see ServiceState#STATE_OUT_OF_SERVICE
 * @see ServiceState#STATE_POWER_OFF
 * @return service state
 */
public String getServiceState() {
	if (DBG)
		Log.d(Config.TAG, TAG + "getServiceState called");
	switch (mServiceStage) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		return "Emergency Only";
	case ServiceState.STATE_IN_SERVICE:
		return "In Service";
	case ServiceState.STATE_POWER_OFF:
		return "Power Off";
	case ServiceState.STATE_OUT_OF_SERVICE:
		return "Out Of Service";
	default:
		return "Unknown";
	}
}
 
開發者ID:adetalhouet,項目名稱:SignalAnalysis,代碼行數:26,代碼來源:PhoneStateHelper.java

示例7: onServiceStateChanged

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	Logs.d("# PhoneStateListener - onServiceStateChanged();");
	int state = serviceState.getState();
	
	switch (state) {
	case ServiceState.STATE_IN_SERVICE:
		Logs.d("# PhoneStateListener - onServiceStateChanged(); - reserve update");
		reserveRemoteUpdate(DEFAULT_UPDATE_DELAY);
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
	case ServiceState.STATE_EMERGENCY_ONLY:
	case ServiceState.STATE_POWER_OFF:
		ContentObject co = mContentManager.addRFStateObject(state);
		if(mActivityHandler != null)
			mActivityHandler.obtainMessage(Constants.MESSAGE_RF_STATE_RECEIVED, co).sendToTarget();
		// send to device
		if(co != null)
			sendContentsToDevice(co);
		else
			deleteEmergencyOfDevice(EmergencyObject.EMERGENCY_TYPE_RF_STATE);
		break;
	}
}
 
開發者ID:godstale,項目名稱:retrowatch,代碼行數:25,代碼來源:RetroWatchService.java

示例8: onServiceStateChanged

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	int state = serviceState.getState();
	
	switch (state) {
	case ServiceState.STATE_IN_SERVICE:
	case ServiceState.STATE_OUT_OF_SERVICE:
	case ServiceState.STATE_EMERGENCY_ONLY:
	case ServiceState.STATE_POWER_OFF:
		ContentObject co = mContentManager.addRFStateObject(state);
		if(mActivityHandler != null)
			mActivityHandler.obtainMessage(Constants.MESSAGE_RF_STATE_RECEIVED, co).sendToTarget();
		// send to device
		if(co != null)
			sendContentsToDevice(co);
		else
			deleteEmergencyOfDevice(EmergencyObject.EMERGENCY_TYPE_RF_STATE);
		break;
	}
}
 
開發者ID:godstale,項目名稱:retrowatch,代碼行數:21,代碼來源:RetroWatchService.java

示例9: onReceive

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(intent.getAction())) {
        if (LOCAL_LOGV) {
            Log.v(TAG, "Service state changed: " + intent.getExtras());
        }

        ServiceState state = ServiceState.newFromBundle(intent.getExtras());
        boolean isRoaming = state.getRoaming();
        if (LOCAL_LOGV) {
            Log.v(TAG, "roaming ------> " + isRoaming);
        }
        synchronized (sInstance) {
            mAutoDownload = getAutoDownloadState(mPreferences, isRoaming);
            if (LOCAL_LOGV) {
                Log.v(TAG, "mAutoDownload ------> " + mAutoDownload);
            }
        }
    }
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:21,代碼來源:DownloadManager.java

示例10: listenRoamingState

import android.telephony.ServiceState; //導入依賴的package包/類
public void listenRoamingState() {
	if (phoneStateListener == null) {
		phoneStateListener = new PhoneStateListener() {
			@Override
			public void onServiceStateChanged(ServiceState serviceState) {
				super.onServiceStateChanged(serviceState);

				final int state = serviceState.getState();
				if (state == ServiceState.STATE_IN_SERVICE
						|| state == ServiceState.STATE_POWER_OFF) {
					final boolean roamingState = serviceState
							.getRoaming();
					if (roamingState != isRoamingOn()) {
						setRoamingOn(roamingState);
					}
				}
			}
		};
	}

	TelephonyManager telMgr = (TelephonyManager) context
			.getSystemService(Context.TELEPHONY_SERVICE);
	telMgr.listen(phoneStateListener,
			PhoneStateListener.LISTEN_SERVICE_STATE);
}
 
開發者ID:naver,項目名稱:android-utilset,代碼行數:26,代碼來源:NetworkMonitor.java

示例11: startTracking

import android.telephony.ServiceState; //導入依賴的package包/類
public void startTracking(){
       mTelephonyManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
       
       /* Check if it is a CDMA phone */
       if(mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
       	tv1 = (TextView) findViewById(R.id.err_msg);
       	tv1.setText("This application can detect a femtocell on a CDMA phone only.");
       	return;
       }
       
       mListener = new PhoneStateListener() {
   		 public void onServiceStateChanged(ServiceState s){
   			 Log.d(TAG, "Service State changed!");
   			 getServiceStateInfo(s);
   		 }
   	};
   	mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
   	mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
 
開發者ID:iSECPartners,項目名稱:femtocatcher,代碼行數:20,代碼來源:MainActivity.java

示例12: getOperatorState

import android.telephony.ServiceState; //導入依賴的package包/類
public String getOperatorState() {
    if (!mHasTelephony) {
        return null;
    }
    if (mServiceState == null || mServiceState.getState() == ServiceState.STATE_OUT_OF_SERVICE) {
        return mGbResources.getString(R.string.pie_phone_status_no_service);
    }
    if (mServiceState.getState() == ServiceState.STATE_POWER_OFF) {
        return mGbResources.getString(R.string.pie_phone_status_airplane_mode);
    }
    if ((Boolean)XposedHelpers.callMethod(mServiceState, "isEmergencyOnly")) {
        return mGbResources.getString(R.string.pie_phone_status_emergency_only);
    }
    return mServiceState.getOperatorAlphaLong();
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:16,代碼來源:PieController.java

示例13: onServiceStateChanged

import android.telephony.ServiceState; //導入依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState){      
  if (serviceState.getState() == ServiceState.STATE_IN_SERVICE ) {
    Intent intent = new Intent(ServiceAvailableEvent.ACTION_NAME);
    context.sendBroadcast(intent);
    serviceAvailable = true;
  } else {
    serviceAvailable = false;
  }
}
 
開發者ID:biotinker,項目名稱:LibreTasks,代碼行數:11,代碼來源:PhoneStateMonitor.java

示例14: type

import android.telephony.ServiceState; //導入依賴的package包/類
public static SubjectFactory<ServiceStateSubject, ServiceState> type() {
  return new SubjectFactory<ServiceStateSubject, ServiceState>() {
    @Override
    public ServiceStateSubject getSubject(FailureStrategy fs, ServiceState that) {
      return new ServiceStateSubject(fs, that);
    }
  };
}
 
開發者ID:pkware,項目名稱:truth-android,代碼行數:9,代碼來源:ServiceStateSubject.java

示例15: getServiceStateInfo

import android.telephony.ServiceState; //導入依賴的package包/類
private void getServiceStateInfo(ServiceState s) {
    if (s != null) {
        if (IsConnectedToCdmaFemto(s)) {
            Helpers.msgShort(context, context.getString(R.string.alert_femtocell_tracking_detected));
            femtoDetected = true;
            setNotification();
            //toggleRadio();
        } else {
            femtoDetected = false;
            setNotification();
        }
    }
}
 
開發者ID:anticomarley,項目名稱:Android-IMSI-Catcher-Detector,代碼行數:14,代碼來源:CellTracker.java


注:本文中的android.telephony.ServiceState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。