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


Java ServiceState.getState方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
public void onServiceStateChanged(ServiceState serviceState)
{
	TextView myservicestate = (TextView)findViewById(R.id.myservicestate);
	int state = serviceState.getState();
	switch(state){
		case ServiceState.STATE_EMERGENCY_ONLY: myservicestate.setText("EMERGENCY ONLY"); break;
		case ServiceState.STATE_IN_SERVICE: myservicestate.setText("IN SERVICE"); break;
		case ServiceState.STATE_OUT_OF_SERVICE: myservicestate.setText("OUT OF SERVICE"); break;
		case ServiceState.STATE_POWER_OFF: myservicestate.setText("POWER OFF"); break;
	}
}
 
開發者ID:baharxy,項目名稱:mobility-logger,代碼行數:12,代碼來源:MainActivity.java

示例6: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
/**
 * Callback invoked when device service state changes.
 * 
 * @see ServiceState#STATE_EMERGENCY_ONLY
 * @see ServiceState#STATE_IN_SERVICE
 * @see ServiceState#STATE_OUT_OF_SERVICE
 * @see ServiceState#STATE_POWER_OFF
 */
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	if (DBG)
		Log.d(Config.TAG, TAG + "onServiceStateChanged called");
	if (mServiceStage != serviceState.getState()) {
		mServiceStage = serviceState.getState();
		isRoaming = serviceState.getRoaming();
	}
}
 
開發者ID:adetalhouet,項目名稱:SignalAnalysis,代碼行數:18,代碼來源:PhoneStateHelper.java

示例7: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
@Override
   public void onServiceStateChanged(ServiceState serviceState) {
	super.onServiceStateChanged(serviceState);
	int state = serviceState.getState();
	int cmState = CallMonitorService.MSG_SERVER_STATE_OUTSERVICE;
	if(state == ServiceState.STATE_IN_SERVICE) {
		cmState = CallMonitorService.MSG_SERVER_STATE_INSERVICE;
	}
	mCmIf.csmif_ServiceState(cmState);
}
 
開發者ID:Spinlogic,項目名稱:VoLTE_Dialer,代碼行數:11,代碼來源:CallMonitorReceiver.java

示例8: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState state) {
  if (state.getState() == ServiceState.STATE_IN_SERVICE) {
    Log.w("SystemStateListener", "In service, sending sms/mms outboxes...");
    sendSmsOutbox(context);
    sendMmsOutbox(context);
  }
}
 
開發者ID:Securecom,項目名稱:Securecom-Text,代碼行數:9,代碼來源:SystemStateListener.java

示例9: handleServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
private void handleServiceStateChanged(Intent intent) {
    // If service just returned, start sending out the queued messages
    ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
    int subscription = intent.getIntExtra(SUBSCRIPTION_KEY, 0);
    int prefSubscription = MSimSmsManager.getDefault().getPreferredSmsSubscription();
    // if service state is IN_SERVICE & current subscription is same as
    // preferred SMS subscription.i.e.as set under MultiSIM Settings,then
    // sendFirstQueuedMessage.
    if (serviceState.getState() == ServiceState.STATE_IN_SERVICE &&
        subscription == prefSubscription) {
        sendFirstQueuedMessage();
    }
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:14,代碼來源:SmsReceiverService.java

示例10: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	super.onServiceStateChanged(serviceState);
	String phonestate = "";
	// set the state of the service - serviceState according to the value in
	// serviceState
	switch (serviceState.getState()) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		if (PhoneNumberUtils.isEmergencyNumber(this.number))
			phonestate = context.getResources().getString(
					R.string.state_in_service);
		else
			phonestate = context.getResources().getString(
					R.string.emergency_calls_only);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
		phonestate = context.getResources().getString(R.string.no_service);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_POWER_OFF:
		phonestate = context.getResources().getString(R.string.power_off);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_IN_SERVICE:
		phonestate = context.getResources().getString(
				R.string.state_in_service);
		setServiceState(phonestate);
		break;
	default:
		phonestate = context.getResources().getString(
				R.string.service_unknown_reason);
		setServiceState(phonestate);
	}
}
 
開發者ID:saurabh2590,項目名稱:EasyAccess,代碼行數:36,代碼來源:CallManager.java

示例11: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
public void onServiceStateChanged(ServiceState serviceState) {
	switch (serviceState.getState()) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		powerEstimator.writeToLog("phone-service emergency-only\n");
		break;
	case ServiceState.STATE_IN_SERVICE:
		powerEstimator.writeToLog("phone-service in-service\n");
		switch (phoneManager.getNetworkType()) {
		case (TelephonyManager.NETWORK_TYPE_EDGE):
			powerEstimator.writeToLog("phone-network edge\n");
			break;
		case (TelephonyManager.NETWORK_TYPE_GPRS):
			powerEstimator.writeToLog("phone-network GPRS\n");
			break;
		case 8:
			powerEstimator.writeToLog("phone-network HSDPA\n");
			break;
		case (TelephonyManager.NETWORK_TYPE_UMTS):
			powerEstimator.writeToLog("phone-network UMTS\n");
			break;
		default:
			powerEstimator.writeToLog("phone-network "
					+ phoneManager.getNetworkType() + "\n");
		}
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
		powerEstimator.writeToLog("phone-service out-of-service\n");
		break;
	case ServiceState.STATE_POWER_OFF:
		powerEstimator.writeToLog("phone-service power-off\n");
		break;
	}
}
 
開發者ID:jackvt93,項目名稱:Open-Battery-Saver,代碼行數:34,代碼來源:UMLoggerService.java

示例12: handleServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
private void handleServiceStateChanged(Intent intent) {
    // If service just returned, start sending out the queued messages
    ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
    if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
        sendFirstQueuedMessage();
    }
}
 
開發者ID:slvn,項目名稱:android-aosp-mms,代碼行數:8,代碼來源:SmsReceiverService.java

示例13: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState) {
  this.connected = (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
  looper.quit();
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:6,代碼來源:TelephonyServiceState.java

示例14: onServiceStateChanged

import android.telephony.ServiceState; //導入方法依賴的package包/類
@Override
public void onServiceStateChanged(ServiceState serviceState) {
  if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
    handleInService();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:7,代碼來源:ServiceRequirementProvider.java

示例15: sendSms

import android.telephony.ServiceState; //導入方法依賴的package包/類
public static void sendSms(final Context context) {
    Log.v(CRDAlarmReceiver.class.getName(), "sendSms() => Sending SMS...");

    CRDSharedPreferences.getInstance(context).setSendingSmsEpoch();

    final TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService(TELEPHONY_SERVICE);
    final PhoneStateListener phoneStateListener = new PhoneStateListener() {
        // Fired when the service state changes or immediately after registration via .listen()
        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
            super.onServiceStateChanged(serviceState);

            String serviceStateDebug;

            switch (serviceState.getState()) {
                case ServiceState.STATE_IN_SERVICE:
                    serviceStateDebug = "STATE_IN_SERVICE";
                    break;
                case ServiceState.STATE_OUT_OF_SERVICE:
                    serviceStateDebug = "OUT_OF_SERVICE";
                    break;
                case ServiceState.STATE_EMERGENCY_ONLY:
                    serviceStateDebug = "EMERGENCY_ONLY";
                    break;
                case ServiceState.STATE_POWER_OFF:
                    serviceStateDebug = "POWER_OFF";
                    break;
                default:
                    serviceStateDebug = "OTHER";
                    break;
            }

            Log.v(CRDAlarmReceiver.class.getName(), "onServiceStateChanged() => " + "serviceState = [" + serviceStateDebug + "]");

            if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
                CRDUtils.sendSmsToOrange(context);

                telephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
            }
        }
    };

    // We can't simply have the current state of the network. We have to register to its changes, then it will fire
    // immediately after the registration an event with the initial state. Super retarded imo.
    telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
 
開發者ID:NinoDLC,項目名稱:CineReminDay,代碼行數:47,代碼來源:CRDAlarmReceiver.java


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